{"id":812,"date":"2025-08-04T17:06:12","date_gmt":"2025-08-04T08:06:12","guid":{"rendered":"https:\/\/nexive.tech\/?p=812"},"modified":"2025-08-04T17:06:13","modified_gmt":"2025-08-04T08:06:13","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-%e3%83%a1%e3%83%bc%e3%83%ab%e3%82%a2%e3%83%89%e3%83%ac%e3%82%b9%e3%83%bb%e6%95%b0%e5%80%a4%e3%81%ae%e5%9e%8b%e3%83%81","status":"publish","type":"post","link":"https:\/\/nexive.tech\/?p=812","title":{"rendered":"\u3010\u30b5\u30af\u30c3\u3068\u89e3\u8aac\u3011PHP \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u30fb\u6570\u5024\u306e\u578b\u30c1\u30a7\u30c3\u30af\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\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3084\u6570\u5024\u306e\u578b\u30c1\u30a7\u30c3\u30af\u65b9\u6cd5\u3092\u6574\u7406<\/li>\n\n\n\n<li><code>filter_var<\/code>\u3084<code>is_numeric<\/code>\u306e\u4f7f\u3044\u65b9\u3068\u6319\u52d5\u3092\u5b9f\u4f8b\u3067\u7d39\u4ecb<\/li>\n\n\n\n<li>\u5b9f\u52d9\u3067\u306e\u9078\u5b9a\u57fa\u6e96\u3084\u4f7f\u3044\u5206\u3051\u306e\u30dd\u30a4\u30f3\u30c8\u3092\u660e\u793a<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. PHP\u306e\u578b\u30c1\u30a7\u30c3\u30af\u51e6\u7406\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>PHP\u3067\u306f\u3001\u5165\u529b\u5024\u304c\u671f\u5f85\u3059\u308b\u5f62\u5f0f\uff08\u4f8b\uff1a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3084\u6574\u6570\u306a\u3069\uff09\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u624b\u6bb5\u3068\u3057\u3066\u3001\u578b\u30c1\u30a7\u30c3\u30af\u51e6\u7406\uff08\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff09\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>Web\u30d5\u30a9\u30fc\u30e0\u3084API\u7d4c\u7531\u3067\u53d7\u3051\u53d6\u3063\u305f\u5024\u306f\u57fa\u672c\u7684\u306b\u3059\u3079\u3066\u6587\u5b57\u5217\u3068\u3057\u3066\u6271\u308f\u308c\u308b\u305f\u3081\u3001\u610f\u56f3\u3057\u306a\u3044\u5024\u306e\u6df7\u5165\u3092\u9632\u3050\u305f\u3081\u306b\u3082\u660e\u793a\u7684\u306a\u691c\u8a3c\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u7279\u306b\u6570\u5024\u3084\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306a\u3069\u306e&#8221;\u5f62\u5f0f\u304c\u6c7a\u307e\u3063\u3066\u3044\u308b\u5024&#8221;\u3067\u306f\u3001\u578b\u30c1\u30a7\u30c3\u30af\u306e\u6709\u7121\u306b\u3088\u3063\u3066\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4fe1\u983c\u6027\u306b\u5927\u304d\u304f\u5f71\u97ff\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>PHP\u3067\u306f\u3001<code>filter_var()<\/code>\u3084<code>is_numeric()<\/code>\u3001<code>ctype_digit()<\/code>\u3001\u6b63\u898f\u8868\u73fe\u306a\u3069\u3001\u8907\u6570\u306e\u65b9\u6cd5\u3067\u30c1\u30a7\u30c3\u30af\u304c\u53ef\u80fd\u3067\u3059\u3002\u7528\u9014\u3084\u5165\u529b\u5143\u306b\u5fdc\u3058\u3066\u3001\u9069\u5207\u306a\u624b\u6cd5\u3092\u9078\u3076\u5fc5\u8981\u304c\u3042\u308a\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\">\u6570\u5024\u306e\u30c1\u30a7\u30c3\u30af\uff08\u6574\u6570\u30fb\u5c0f\u6570\uff09<\/h3>\n\n\n\n<p>\u30d5\u30a9\u30fc\u30e0\u304b\u3089\u9001\u3089\u308c\u305f\u5024\u304c<strong>\u6570\u5024\u304b\u3069\u3046\u304b<\/strong>\u3092\u78ba\u8a8d\u3057\u305f\u3044\u5834\u5408\u3001\u6b21\u306e\u3088\u3046\u306a\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">is_numeric(): \u6570\u5024\u5224\u5b9a\uff08\u6574\u6570\u30fb\u5c0f\u6570\u3068\u3082OK\uff09<\/h4>\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 = '123.45';\n\n\/\/ is_numeric\u306f\u6574\u6570\u30fb\u5c0f\u6570\u30fb\u6570\u5024\u5f62\u5f0f\u306e\u6587\u5b57\u5217\u3092\u8a31\u5bb9\nif (is_numeric($value)) {\n    echo \"\u6570\u5024\u3067\u3059\";\n} else {\n    echo \"\u6570\u5024\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: #CE9178\">&#39;123.45&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ is_numeric\u306f\u6574\u6570\u30fb\u5c0f\u6570\u30fb\u6570\u5024\u5f62\u5f0f\u306e\u6587\u5b57\u5217\u3092\u8a31\u5bb9<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #DCDCAA\">is_numeric<\/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\">&quot;\u6570\u5024\u3067\u3059&quot;<\/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;\u6570\u5024\u3067\u306f\u3042\u308a\u307e\u305b\u3093&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>\u51fa\u529b\u7d50\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u6570\u5024\u3067\u3059\n<\/code><\/pre>\n\n\n\n<p><code>is_numeric()<\/code>\u306f\u3001<code>\"123\"<\/code> \u3084 <code>\"3.14\"<\/code> \u306a\u3069\u306e<strong>\u6570\u5024\u8868\u73fe\u306e\u6587\u5b57\u5217<\/strong>\u3082\u771f\u3068\u5224\u5b9a\u3059\u308b\u305f\u3081\u3001<br>\u30d5\u30a9\u30fc\u30e0\u5165\u529b\u5024\u306e\u521d\u671f\u30c1\u30a7\u30c3\u30af\u306a\u3069\u3067\u5e83\u304f\u4f7f\u308f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">ctype_digit(): \u6574\u6570\u306e\u307f\uff08\u6587\u5b57\u5217\u524d\u63d0\uff09<\/h4>\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 = '123';\n\n\/\/ ctype_digit\u306f\"\u6574\u6570\u306e\u6587\u5b57\u5217\"\u306e\u307f\u8a31\u5bb9\nif (ctype_digit($value)) {\n    echo \"\u6574\u6570\u3067\u3059\";\n} else {\n    echo \"\u6574\u6570\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: #CE9178\">&#39;123&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ ctype_digit\u306f&quot;\u6574\u6570\u306e\u6587\u5b57\u5217&quot;\u306e\u307f\u8a31\u5bb9<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #DCDCAA\">ctype_digit<\/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\">&quot;\u6574\u6570\u3067\u3059&quot;<\/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;\u6574\u6570\u3067\u306f\u3042\u308a\u307e\u305b\u3093&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>\u51fa\u529b\u7d50\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u6574\u6570\u3067\u3059\n<\/code><\/pre>\n\n\n\n<p><code>ctype_digit()<\/code>\u306f\u3001\u5c0f\u6570\u3084\u30de\u30a4\u30ca\u30b9\u8a18\u53f7\u3092\u542b\u3080\u5024\uff08\u4f8b\uff1a&#8221;-12&#8243;\u3001&#8221;3.14&#8243;\uff09\u3092\u3059\u3079\u3066\u507d\u3068\u5224\u5b9a\u3057\u307e\u3059\u3002<br>\u3057\u305f\u304c\u3063\u3066\u3001<strong>ID\u3084\u6570\u91cf\u306a\u3069\u6b63\u306e\u6574\u6570\u9650\u5b9a\u306e\u7528\u9014<\/strong>\u3067\u4f7f\u308f\u308c\u308b\u30b1\u30fc\u30b9\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u30c1\u30a7\u30c3\u30af<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">filter_var(): FILTER_VALIDATE_EMAIL<\/h4>\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>$email = 'user@example.com';\n\nif (filter_var($email, FILTER_VALIDATE_EMAIL)) {\n    echo \"\u6b63\u3057\u3044\u30e1\u30fc\u30eb\u5f62\u5f0f\u3067\u3059\";\n} else {\n    echo \"\u7121\u52b9\u306a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\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: #9CDCFE\">$email<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #CE9178\">&#39;user@example.com&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #DCDCAA\">filter_var<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$email<\/span><span style=\"color: #D4D4D4\">, FILTER_VALIDATE_EMAIL)) {<\/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;\u6b63\u3057\u3044\u30e1\u30fc\u30eb\u5f62\u5f0f\u3067\u3059&quot;<\/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;\u7121\u52b9\u306a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3067\u3059&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>\u51fa\u529b\u7d50\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u6b63\u3057\u3044\u30e1\u30fc\u30eb\u5f62\u5f0f\u3067\u3059\n<\/code><\/pre>\n\n\n\n<p><code>filter_var()<\/code>\u95a2\u6570\u306f\u3001PHP\u306b\u7d44\u307f\u8fbc\u307e\u308c\u305f\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u6a5f\u69cb\u3067\u3001<br><code>FILTER_VALIDATE_EMAIL<\/code>\u3092\u4f7f\u3048\u3070\u3001\u57fa\u672c\u7684\u306a\u30e1\u30fc\u30eb\u5f62\u5f0f\u3092\u81ea\u52d5\u7684\u306b\u691c\u8a3c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>HTML\u306e<code>pattern<\/code>\u5c5e\u6027\u3084JavaScript\u3067\u306e\u30c1\u30a7\u30c3\u30af\u3068\u4f75\u7528\u3057\u3066\u3001<br><strong>\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u3067\u3082\u78ba\u5b9f\u306a\u691c\u8a3c\u3092\u884c\u3046<\/strong>\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">filter_var\u3068\u6b63\u898f\u8868\u73fe\u306e\u9055\u3044<\/h3>\n\n\n\n<p>\u30e1\u30fc\u30eb\u3084URL\u306a\u3069\u306e\u5f62\u5f0f\u306f\u3001<code>filter_var<\/code>\u306e\u3088\u3046\u306a<strong>\u30d3\u30eb\u30c8\u30a4\u30f3\u30d5\u30a3\u30eb\u30bf<\/strong>\u306e\u65b9\u304c\u4fe1\u983c\u6027\u3068\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u304c\u9ad8\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4e00\u65b9\u3067\u3001**\u30ab\u30b9\u30bf\u30e0\u306a\u5f62\u5f0f\uff08\u4f8b\uff1a\u7279\u5b9a\u30c9\u30e1\u30a4\u30f3\u306e\u30e1\u30fc\u30eb\u306e\u307f\uff09**\u3092\u30c1\u30a7\u30c3\u30af\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\u65b9\u304c\u67d4\u8edf\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(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>$email = 'admin@example.co.jp';\n\n\/\/ \u300c.co.jp\u300d\u30c9\u30e1\u30a4\u30f3\u306e\u307f\u8a31\u53ef\u3059\u308b\u4f8b\nif (preg_match('\/^&#91;\\w.-&#93;+@(&#91;\\w-&#93;+\\.)+co\\.jp$\/', $email)) {\n    echo \".co.jp\u30c9\u30e1\u30a4\u30f3\u306e\u30e1\u30fc\u30eb\u3067\u3059\";\n} else {\n    echo \"\u5bfe\u8c61\u5916\u306e\u30e1\u30fc\u30eb\u5f62\u5f0f\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: #9CDCFE\">$email<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #CE9178\">&#39;admin@example.co.jp&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A9955\">\/\/ \u300c.co.jp\u300d\u30c9\u30e1\u30a4\u30f3\u306e\u307f\u8a31\u53ef\u3059\u308b\u4f8b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #DCDCAA\">preg_match<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #D16969\">&#39;\/<\/span><span style=\"color: #D4D4D4\">^<\/span><span style=\"color: #D16969\">&#91;\\w.-&#93;<\/span><span style=\"color: #D4D4D4\">+<\/span><span style=\"color: #D16969\">@(&#91;\\w-&#93;<\/span><span style=\"color: #D4D4D4\">+<\/span><span style=\"color: #D7BA7D\">\\.<\/span><span style=\"color: #D16969\">)<\/span><span style=\"color: #D4D4D4\">+<\/span><span style=\"color: #D16969\">co<\/span><span style=\"color: #D7BA7D\">\\.<\/span><span style=\"color: #D16969\">jp<\/span><span style=\"color: #D4D4D4\">$<\/span><span style=\"color: #D16969\">\/&#39;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">$email<\/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;.co.jp\u30c9\u30e1\u30a4\u30f3\u306e\u30e1\u30fc\u30eb\u3067\u3059&quot;<\/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;\u5bfe\u8c61\u5916\u306e\u30e1\u30fc\u30eb\u5f62\u5f0f\u3067\u3059&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>\u51fa\u529b\u7d50\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.co.jp\u30c9\u30e1\u30a4\u30f3\u306e\u30e1\u30fc\u30eb\u3067\u3059\n<\/code><\/pre>\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<ul class=\"wp-block-list\">\n<li><code>is_numeric()<\/code>\u306f\u3001<code>\"0123\"<\/code>\u306e\u3088\u3046\u306a0\u57cb\u3081\u6587\u5b57\u5217\u3082\u771f\u3068\u5224\u5b9a\u3059\u308b\u305f\u3081\u3001<strong>ID\u7528\u9014\u306b\u306f\u4e0d\u9069\u5207<\/strong>\u3067\u3059\u3002<\/li>\n\n\n\n<li><code>ctype_digit()<\/code>\u306f\u3001\u6570\u5024\u3068\u3057\u3066\u306f\u4f7f\u3048\u306a\u3044<code>\" 123\"<\/code>\u3084<code>\"+123\"<\/code>\u3082\u507d\u3068\u5224\u5b9a\u3057\u307e\u3059\u3002\u524d\u51e6\u7406\u304c\u5fc5\u8981\u306a\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>filter_var()<\/code>\u306b\u3088\u308b\u30e1\u30fc\u30eb\u30c1\u30a7\u30c3\u30af\u306f\u3001RFC\u306b\u6e96\u62e0\u3057\u3066\u304a\u3089\u305a\u3001<strong>\u7279\u6b8a\u306a\u30a2\u30c9\u30ec\u30b9\uff08\u4f8b\uff1a\u5f15\u7528\u7b26\u4ed8\u304d\uff09\u3092\u5f3e\u304f<\/strong>\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u6570\u5024\u30c1\u30a7\u30c3\u30af\u306b\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\u3068\u3001\u610f\u56f3\u305b\u306c\u4f8b\u5916\u3084\u7a7a\u767d\u306e\u6271\u3044\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3084\u3059\u3044<\/strong>\u305f\u3081\u3001\u30d3\u30eb\u30c8\u30a4\u30f3\u95a2\u6570\u306e\u5229\u7528\u304c\u63a8\u5968\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u307e\u3068\u3081<\/h2>\n\n\n\n<p>PHP\u306b\u304a\u3051\u308b\u578b\u30c1\u30a7\u30c3\u30af\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u306e\u4fe1\u983c\u6027\u3092\u62c5\u4fdd\u3059\u308b\u305f\u3081\u306b\u4e0d\u53ef\u6b20\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u6570\u5024\u306b\u306f<code>is_numeric<\/code>\u3084<code>ctype_digit<\/code>\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306b\u306f<code>filter_var<\/code>\u3092\u4f7f\u3044\u5206\u3051\u308b\u3053\u3068\u3067\u3001\u5b89\u5168\u6027\u3068\u53ef\u8aad\u6027\u306e\u9ad8\u3044\u30b3\u30fc\u30c9\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7528\u9014\u3054\u3068\u306e\u7279\u6027\u3068\u5236\u9650\u3092\u7406\u89e3\u3057\u305f\u3046\u3048\u3067\u3001\u6700\u9069\u306a\u624b\u6bb5\u3092\u9078\u5b9a\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8 2. PHP\u306e\u578b\u30c1\u30a7\u30c3\u30af\u51e6\u7406\u3068\u306f\uff1f PHP\u3067\u306f\u3001\u5165\u529b\u5024\u304c\u671f\u5f85\u3059\u308b\u5f62\u5f0f\uff08\u4f8b\uff1a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3084\u6574\u6570\u306a\u3069\uff09\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u624b\u6bb5\u3068\u3057\u3066\u3001\u578b\u30c1\u30a7\u30c3\u30af\u51e6\u7406\uff08\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\uff09\u3092\u884c\u3044\u307e\u3059\u3002 Web\u30d5\u30a9\u30fc\u30e0\u3084 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":889,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[85],"tags":[],"class_list":["post-812","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\/812","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=812"}],"version-history":[{"count":2,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/812\/revisions"}],"predecessor-version":[{"id":890,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/812\/revisions\/890"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/media\/889"}],"wp:attachment":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}