{"id":810,"date":"2025-08-04T17:03:56","date_gmt":"2025-08-04T08:03:56","guid":{"rendered":"https:\/\/nexive.tech\/?p=810"},"modified":"2025-08-04T17:03:56","modified_gmt":"2025-08-04T08:03:56","slug":"%e3%80%90%e3%82%b5%e3%82%af%e3%83%83%e3%81%a8%e8%a7%a3%e8%aa%ac%e3%80%91php-%e5%85%a5%e5%8a%9b%e5%80%a4%e3%81%ae%e5%bf%85%e9%a0%88%e3%83%81%e3%82%a7%e3%83%83%e3%82%af%e3%81%a8%e7%a9%ba%e5%88%a4","status":"publish","type":"post","link":"https:\/\/nexive.tech\/?p=810","title":{"rendered":"\u3010\u30b5\u30af\u30c3\u3068\u89e3\u8aac\u3011PHP \u5165\u529b\u5024\u306e\u5fc5\u9808\u30c1\u30a7\u30c3\u30af\u3068\u7a7a\u5224\u5b9a\u51e6\u7406"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP\u3067\u306e\u5165\u529b\u5024\u306e\u5fc5\u9808\u30c1\u30a7\u30c3\u30af\u3084\u7a7a\u5224\u5b9a\u306b\u4f7f\u308f\u308c\u308b\u69cb\u6587\u306e\u9055\u3044\u3068\u7528\u9014\u3092\u6574\u7406<\/li>\n\n\n\n<li><code>isset()<\/code>\u30fb<code>empty()<\/code>\u30fb<code>is_null()<\/code> \u306e\u9055\u3044\u3068\u6ce8\u610f\u70b9\u3092\u660e\u78ba\u5316<\/li>\n\n\n\n<li>\u30d5\u30a9\u30fc\u30e0\u51e6\u7406\u306a\u3069\u3067\u306e\u5b9f\u52d9\u7684\u306a\u4f7f\u3044\u5206\u3051\u6307\u91dd\u3092\u63d0\u793a<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. PHP\u306e\u5165\u529b\u5024\u306e\u5fc5\u9808\u30c1\u30a7\u30c3\u30af\u3068\u7a7a\u5224\u5b9a\u51e6\u7406\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>PHP\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u3092\u53d7\u3051\u53d6\u3063\u305f\u969b\u306b\u300c\u5165\u529b\u304c\u3042\u308b\u304b\u300d\u300c\u5024\u304c\u7a7a\u3067\u306a\u3044\u304b\u300d\u3092\u5224\u5b9a\u3059\u308b\u51e6\u7406\u304c\u5fc5\u8981\u3067\u3059\u3002\u3053\u308c\u306f\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3084\u696d\u52d9\u30ed\u30b8\u30c3\u30af\u306e\u89b3\u70b9\u304b\u3089\u3082\u91cd\u8981\u306a\u524d\u51e6\u7406\u306b\u3042\u305f\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305f\u3068\u3048\u3070\u3001\u30d5\u30a9\u30fc\u30e0\u9001\u4fe1\u3055\u308c\u305f\u5024\u3092\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3059\u308b\u969b\u3001\u300c\u672a\u5165\u529b\u300d\u3084\u300c\u7a7a\u6587\u5b57\u300d\u306e\u72b6\u614b\u3092\u6b63\u3057\u304f\u5224\u5b9a\u3067\u304d\u306a\u3044\u3068\u3001\u60f3\u5b9a\u5916\u306e\u6319\u52d5\u3084\u30d0\u30b0\u306e\u539f\u56e0\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u5165\u529b\u30c1\u30a7\u30c3\u30af\u3067\u306f\u4e3b\u306b <code>isset()<\/code>\u3001<code>empty()<\/code>\u3001<code>is_null()<\/code>\u3001\u5834\u5408\u306b\u3088\u3063\u3066\u306f <code>filter_input()<\/code> \u3068\u3044\u3063\u305f\u95a2\u6570\u304c\u5229\u7528\u3055\u308c\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u305d\u308c\u305e\u308c\u306e\u95a2\u6570\u304c\u5224\u5b9a\u3059\u308b\u6761\u4ef6\u306f\u5fae\u5999\u306b\u7570\u306a\u308b\u305f\u3081\u3001\u8aa4\u7528\u3059\u308b\u3068\u30d0\u30b0\u3092\u5f15\u304d\u8d77\u3053\u3059\u30ea\u30b9\u30af\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001\u305d\u308c\u305e\u308c\u306e\u69cb\u6587\u306e\u4ed5\u69d8\u3068\u9055\u3044\u3001\u5b9f\u52d9\u306b\u304a\u3051\u308b\u9069\u5207\u306a\u4f7f\u3044\u65b9\u3092\u6574\u7406\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u8a73\u7d30\u89e3\u8aac<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a9\u30fc\u30e0\u306e\u5165\u529b\u5024\u304c\u9001\u4fe1\u3055\u308c\u305f\u304b\u3069\u3046\u304b\u306e\u5224\u5b9a\u306b\u306f <code>isset()<\/code><\/h3>\n\n\n\n<p>POST\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3059\u308b\u304b\u3092\u5224\u5b9a\u3059\u308b\u969b\u306b\u306f <code>isset()<\/code> \u304c\u3088\u304f\u4f7f\u308f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ \u30d5\u30a9\u30fc\u30e0\u304b\u3089\u306e\u5165\u529b\u304c\u5b58\u5728\u3059\u308b\u304b\u30c1\u30a7\u30c3\u30af\nif (isset($_POST&#91;'username'&#93;)) {\n    echo '\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u9001\u4fe1\u3055\u308c\u307e\u3057\u305f';\n} else {\n    echo '\u30e6\u30fc\u30b6\u30fc\u540d\u306f\u672a\u9001\u4fe1\u3067\u3059';\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u30d5\u30a9\u30fc\u30e0\u304b\u3089\u306e\u5165\u529b\u304c\u5b58\u5728\u3059\u308b\u304b\u30c1\u30a7\u30c3\u30af<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #DCDCAA\">isset<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$_POST<\/span><span style=\"color: #D4D4D4\">&#91;<\/span><span style=\"color: #CE9178\">&#39;username&#39;<\/span><span style=\"color: #D4D4D4\">&#93;)) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&#39;\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u9001\u4fe1\u3055\u308c\u307e\u3057\u305f&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">} <\/span><span style=\"color: #C586C0\">else<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&#39;\u30e6\u30fc\u30b6\u30fc\u540d\u306f\u672a\u9001\u4fe1\u3067\u3059&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><code>isset()<\/code> \u306f\u3001\u5909\u6570\u304c\u672a\u5b9a\u7fa9\u307e\u305f\u306f <code>null<\/code> \u306e\u5834\u5408\u306b false \u3092\u8fd4\u3057\u307e\u3059\u3002\u7a7a\u6587\u5b57\u30840\u306ftrue\u6271\u3044\u306b\u306a\u308b\u305f\u3081\u3001<strong>\u300c\u5024\u304c\u7a7a\u304b\u3069\u3046\u304b\u300d\u3067\u306f\u306a\u304f\u300c\u5b58\u5728\u3059\u308b\u304b\u300d\u3092\u30c1\u30a7\u30c3\u30af<\/strong>\u3059\u308b\u306e\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7a7a\u5024\u3082\u542b\u3081\u3066\u5165\u529b\u306e\u6709\u7121\u3092\u30c1\u30a7\u30c3\u30af\u3057\u305f\u3044\u306a\u3089 <code>empty()<\/code><\/h3>\n\n\n\n<p>\u30e6\u30fc\u30b6\u30fc\u304c\u5024\u3092\u5165\u529b\u3057\u305f\u304b\u3092\u78ba\u8a8d\u3059\u308b\u5834\u5408\u306f <code>empty()<\/code> \u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ \u7a7a\u5224\u5b9a\u306e\u4f8b\uff080\u3084\u7a7a\u6587\u5b57\u306ffalse\u6271\u3044\uff09\nif (empty($_POST&#91;'email'&#93;)) {\n    echo '\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093';\n} else {\n    echo '\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u5165\u529b\u3055\u308c\u307e\u3057\u305f';\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u7a7a\u5224\u5b9a\u306e\u4f8b\uff080\u3084\u7a7a\u6587\u5b57\u306ffalse\u6271\u3044\uff09<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #DCDCAA\">empty<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$_POST<\/span><span style=\"color: #D4D4D4\">&#91;<\/span><span style=\"color: #CE9178\">&#39;email&#39;<\/span><span style=\"color: #D4D4D4\">&#93;)) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&#39;\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u5165\u529b\u3055\u308c\u3066\u3044\u307e\u305b\u3093&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">} <\/span><span style=\"color: #C586C0\">else<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&#39;\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u5165\u529b\u3055\u308c\u307e\u3057\u305f&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><code>empty()<\/code> \u306f\u3001\u7a7a\u6587\u5b57\u30fb0\u30fb&#8221;0&#8243;\u30fbnull\u30fbfalse\u30fb\u7a7a\u914d\u5217\u306a\u3069\u3092\u3059\u3079\u3066 false \u3068\u3057\u3066\u6271\u3044\u307e\u3059\u3002<strong>\u300c\u610f\u5473\u306e\u3042\u308b\u5024\u304c\u5165\u3063\u3066\u3044\u308b\u304b\u300d\u3092\u5224\u5b9a\u3059\u308b\u306e\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u53b3\u5bc6\u306bnull\u306e\u307f\u3092\u691c\u51fa\u3057\u305f\u3044\u306a\u3089 <code>is_null()<\/code><\/h3>\n\n\n\n<p>\u5909\u6570\u304c <code>null<\/code> \u304b\u3069\u3046\u304b\u3092\u53b3\u5bc6\u306b\u30c1\u30a7\u30c3\u30af\u3057\u305f\u3044\u5834\u5408\u306f <code>is_null()<\/code> \u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>$value = null;\nif (is_null($value)) {\n    echo '\u5024\u306fnull\u3067\u3059';\n} else {\n    echo 'null\u3067\u306f\u3042\u308a\u307e\u305b\u3093';\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">$value<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #569CD6\">null<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #DCDCAA\">is_null<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$value<\/span><span style=\"color: #D4D4D4\">)) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&#39;\u5024\u306fnull\u3067\u3059&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">} <\/span><span style=\"color: #C586C0\">else<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&#39;null\u3067\u306f\u3042\u308a\u307e\u305b\u3093&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u95a2\u6570\u306f\u300c\u5024\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u3066\u3001\u304b\u3064null\u300d\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u3001\u672a\u5b9a\u7fa9\u5909\u6570\u3092\u6e21\u3059\u3068\u8b66\u544a\u304c\u51fa\u308b\u70b9\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a3\u30eb\u30bf\u3068\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u540c\u6642\u306b\u884c\u3046 <code>filter_input()<\/code><\/h3>\n\n\n\n<p>\u5916\u90e8\u5165\u529b\u5024\u306b\u5bfe\u3057\u3066\u3001\u5b58\u5728\u30c1\u30a7\u30c3\u30af\u3068\u30d5\u30a3\u30eb\u30bf\u3092\u540c\u6642\u306b\u884c\u3044\u305f\u3044\u5834\u5408\u306f <code>filter_input()<\/code> \u304c\u6709\u52b9\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ \u5165\u529b\u304c\u5b58\u5728\u3057\u3066\u3001\u304b\u3064\u7a7a\u3067\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\n$username = filter_input(INPUT_POST, 'username', FILTER_DEFAULT);\nif ($username === null) {\n    echo '\u5165\u529b\u304c\u5b58\u5728\u3057\u307e\u305b\u3093';\n} elseif ($username === '') {\n    echo '\u7a7a\u6587\u5b57\u304c\u5165\u529b\u3055\u308c\u307e\u3057\u305f';\n} else {\n    echo \"\u5165\u529b\u3055\u308c\u305f\u30e6\u30fc\u30b6\u30fc\u540d: $username\";\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u5165\u529b\u304c\u5b58\u5728\u3057\u3066\u3001\u304b\u3064\u7a7a\u3067\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$username<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">filter_input<\/span><span style=\"color: #D4D4D4\">(INPUT_POST, <\/span><span style=\"color: #CE9178\">&#39;username&#39;<\/span><span style=\"color: #D4D4D4\">, FILTER_DEFAULT);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$username<\/span><span style=\"color: #D4D4D4\"> === <\/span><span style=\"color: #569CD6\">null<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&#39;\u5165\u529b\u304c\u5b58\u5728\u3057\u307e\u305b\u3093&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">} <\/span><span style=\"color: #C586C0\">elseif<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #9CDCFE\">$username<\/span><span style=\"color: #D4D4D4\"> === <\/span><span style=\"color: #CE9178\">&#39;&#39;<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&#39;\u7a7a\u6587\u5b57\u304c\u5165\u529b\u3055\u308c\u307e\u3057\u305f&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">} <\/span><span style=\"color: #C586C0\">else<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;\u5165\u529b\u3055\u308c\u305f\u30e6\u30fc\u30b6\u30fc\u540d: <\/span><span style=\"color: #9CDCFE\">$username<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u5916\u90e8\u5165\u529b\u306e\u30c1\u30a7\u30c3\u30af\u306b\u306f <code>isset()<\/code> \u3060\u3051\u3067\u306a\u304f\u3001\u72b6\u6cc1\u306b\u5fdc\u3058\u3066 <code>empty()<\/code> \u3084 <code>filter_input()<\/code> \u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u3088\u304f\u3042\u308b\u30df\u30b9\u30fb\u8aa4\u89e3\u30fb\u843d\u3068\u3057\u7a74<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><code>empty()<\/code> \u306f0\u3092\u300c\u7a7a\u300d\u3068\u898b\u306a\u3059<\/h3>\n\n\n\n<p><code>empty(0)<\/code> \u306ftrue\u3092\u8fd4\u3059\u305f\u3081\u3001\u6570\u5024\u306e0\u304c\u6709\u52b9\u306a\u5165\u529b\u5024\u306e\u5834\u5408\u306b\u306f\u4e0d\u9069\u5207\u3067\u3059\u3002\u3053\u306e\u3088\u3046\u306a\u30b1\u30fc\u30b9\u3067\u306f <code>trim()<\/code> \u3084 <code>=== ''<\/code> \u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u5224\u5b9a\u3059\u308b\u3053\u3068\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>isset()<\/code> \u3060\u3051\u3067\u306f\u7a7a\u6587\u5b57\u3092\u5f3e\u3051\u306a\u3044<\/h3>\n\n\n\n<p>\u5909\u6570\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u304b\u3060\u3051\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b <code>isset()<\/code> \u306f\u3001\u7a7a\u6587\u5b57\u30840\u3082true\u3068\u5224\u5b9a\u3059\u308b\u305f\u3081\u3001\u5b9f\u8cea\u7684\u306b\u672a\u5165\u529b\u3092\u691c\u51fa\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>is_null()<\/code> \u306f\u672a\u5b9a\u7fa9\u5909\u6570\u306b\u4f7f\u3046\u3068\u8b66\u544a\u304c\u51fa\u308b<\/h3>\n\n\n\n<p><code>is_null()<\/code> \u306f\u5909\u6570\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u524d\u63d0\u3067\u3059\u3002\u5b58\u5728\u30c1\u30a7\u30c3\u30af\u3092\u4f34\u308f\u306a\u3044\u4f7f\u7528\u306f\u3001Notice\u30ec\u30d9\u30eb\u306e\u30a8\u30e9\u30fc\u306b\u3064\u306a\u304c\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>filter_input()<\/code> \u306e\u623b\u308a\u5024\u306b\u6ce8\u610f<\/h3>\n\n\n\n<p><code>filter_input()<\/code> \u306f\u3001\u5bfe\u8c61\u306e\u30ad\u30fc\u304c\u5b58\u5728\u3057\u306a\u3051\u308c\u3070 null\u3001\u5b58\u5728\u3057\u3066\u3082\u7a7a\u306a\u3089\u7a7a\u6587\u5b57\u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u306e2\u3064\u3092\u533a\u5225\u3059\u308b\u3053\u3068\u3067\u3001\u30d5\u30a9\u30fc\u30e0\u306e\u300c\u672a\u9001\u4fe1\u300d\u3068\u300c\u7a7a\u5165\u529b\u300d\u306e\u5224\u5b9a\u3092\u660e\u78ba\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u307e\u3068\u3081<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5165\u529b\u5024\u306e\u5b58\u5728\u78ba\u8a8d\u306f <code>isset()<\/code>\u3001\u5185\u5bb9\u30c1\u30a7\u30c3\u30af\u306f <code>empty()<\/code> \u3092\u4f7f\u3044\u5206\u3051\u308b<\/li>\n\n\n\n<li>null\u3060\u3051\u3092\u691c\u51fa\u3057\u305f\u3044\u3068\u304d\u306f <code>is_null()<\/code> \u3092\u4f7f\u3046\uff08\u672a\u5b9a\u7fa9\u5909\u6570\u306b\u306f\u6ce8\u610f\uff09<\/li>\n\n\n\n<li>\u5b9f\u52d9\u3067\u306f <code>filter_input()<\/code> \u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u3001\u9001\u4fe1\u3068\u7a7a\u6587\u5b57\u3092\u660e\u78ba\u306b\u5224\u5225\u3059\u308b\u8a2d\u8a08\u304c\u63a8\u5968\u3055\u308c\u308b<\/li>\n\n\n\n<li>\u7279\u306b\u30d5\u30a9\u30fc\u30e0\u51e6\u7406\u3067\u306f\u30010\u3084\u7a7a\u6587\u5b57\u3092\u6b63\u3057\u304f\u6271\u3048\u308b\u3088\u3046\u6761\u4ef6\u5206\u5c90\u3092\u8a2d\u8a08\u3059\u308b\u3053\u3068\u304c\u91cd\u8981<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8 2. PHP\u306e\u5165\u529b\u5024\u306e\u5fc5\u9808\u30c1\u30a7\u30c3\u30af\u3068\u7a7a\u5224\u5b9a\u51e6\u7406\u3068\u306f\uff1f PHP\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u3092\u53d7\u3051\u53d6\u3063\u305f\u969b\u306b\u300c\u5165\u529b\u304c\u3042\u308b\u304b\u300d\u300c\u5024\u304c\u7a7a\u3067\u306a\u3044\u304b\u300d\u3092\u5224\u5b9a\u3059\u308b\u51e6\u7406\u304c\u5fc5\u8981\u3067\u3059\u3002\u3053\u308c\u306f\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3084\u696d\u52d9\u30ed\u30b8\u30c3\u30af\u306e\u89b3\u70b9\u304b\u3089 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":887,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[85],"tags":[],"class_list":["post-810","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=810"}],"version-history":[{"count":2,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/810\/revisions"}],"predecessor-version":[{"id":888,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/810\/revisions\/888"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/media\/887"}],"wp:attachment":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}