{"id":139,"date":"2025-02-14T17:53:16","date_gmt":"2025-02-14T08:53:16","guid":{"rendered":"https:\/\/pclife-qa.com\/?p=139"},"modified":"2025-02-14T17:53:50","modified_gmt":"2025-02-14T08:53:50","slug":"php-%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be","status":"publish","type":"post","link":"https:\/\/pclife-qa.com\/?p=139","title":{"rendered":"PHP \u6b63\u898f\u8868\u73fe"},"content":{"rendered":"\n<p>PHP\u3067\u4f7f\u7528\u3055\u308c\u308b\u6b63\u898f\u8868\u73fe\uff08\u6b63\u898f\u8868\u73fe\u30d1\u30bf\u30fc\u30f3\uff09\u306f\u3001\u6587\u5b57\u5217\u64cd\u4f5c\u3084\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u306b\u975e\u5e38\u306b\u4fbf\u5229\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001PHP\u3067\u3088\u304f\u4f7f\u308f\u308c\u308b\u6b63\u898f\u8868\u73fe\u306e\u4e00\u89a7\u3068\u305d\u306e\u8aac\u660e\u3092\u7c21\u5358\u306b\u307e\u3068\u3081\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>\u57fa\u672c\u69cb\u6587<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\/pattern\/<\/code>: PHP\u3067\u6b63\u898f\u8868\u73fe\u3092\u8a18\u8ff0\u3059\u308b\u969b\u306e\u57fa\u672c\u5f62\u5f0f\u3002\u30b9\u30e9\u30c3\u30b7\u30e5<code>\/<\/code>\u3067\u56f2\u3080\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>\u6587\u5b57\u30af\u30e9\u30b9<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30d1\u30bf\u30fc\u30f3<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>.<\/code><\/td><td>\u4efb\u610f\u306e1\u6587\u5b57\uff08\u6539\u884c\u3092\u9664\u304f\uff09<\/td><\/tr><tr><td><code>\\d<\/code><\/td><td>\u6570\u5b57\uff080\uff5e9\uff09<\/td><\/tr><tr><td><code>\\D<\/code><\/td><td>\u6570\u5b57\u4ee5\u5916\u306e\u6587\u5b57<\/td><\/tr><tr><td><code>\\w<\/code><\/td><td>\u82f1\u6570\u5b57\u307e\u305f\u306f\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\uff08[a-zA-Z0-9_]\uff09<\/td><\/tr><tr><td><code>\\W<\/code><\/td><td>\u82f1\u6570\u5b57\u307e\u305f\u306f\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u4ee5\u5916<\/td><\/tr><tr><td><code>\\s<\/code><\/td><td>\u7a7a\u767d\u6587\u5b57\uff08\u30b9\u30da\u30fc\u30b9\u3001\u30bf\u30d6\u3001\u6539\u884c\u306a\u3069\uff09<\/td><\/tr><tr><td><code>\\S<\/code><\/td><td>\u7a7a\u767d\u6587\u5b57\u4ee5\u5916<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>\u91cf\u6307\u5b9a\u5b50<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30d1\u30bf\u30fc\u30f3<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>*<\/code><\/td><td>0\u56de\u4ee5\u4e0a\u306e\u7e70\u308a\u8fd4\u3057<\/td><\/tr><tr><td><code>+<\/code><\/td><td>1\u56de\u4ee5\u4e0a\u306e\u7e70\u308a\u8fd4\u3057<\/td><\/tr><tr><td><code>?<\/code><\/td><td>0\u56de\u307e\u305f\u306f1\u56de\u306e\u51fa\u73fe<\/td><\/tr><tr><td><code>{n}<\/code><\/td><td>\u3061\u3087\u3046\u3069n\u56de\u306e\u7e70\u308a\u8fd4\u3057<\/td><\/tr><tr><td><code>{n,}<\/code><\/td><td>n\u56de\u4ee5\u4e0a\u306e\u7e70\u308a\u8fd4\u3057<\/td><\/tr><tr><td><code>{n,m}<\/code><\/td><td>n\u56de\u4ee5\u4e0am\u56de\u4ee5\u4e0b\u306e\u7e70\u308a\u8fd4\u3057<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>\u30a2\u30f3\u30ab\u30fc\uff08\u4f4d\u7f6e\u6307\u5b9a\uff09<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30d1\u30bf\u30fc\u30f3<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>^<\/code><\/td><td>\u884c\u982d\u3092\u6307\u5b9a<\/td><\/tr><tr><td><code>$<\/code><\/td><td>\u884c\u672b\u3092\u6307\u5b9a<\/td><\/tr><tr><td><code>\\b<\/code><\/td><td>\u5358\u8a9e\u306e\u5883\u754c<\/td><\/tr><tr><td><code>\\B<\/code><\/td><td>\u5358\u8a9e\u306e\u5883\u754c\u4ee5\u5916<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>\u30b0\u30eb\u30fc\u30d7\u5316\u3068\u9078\u629e<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30d1\u30bf\u30fc\u30f3<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>(abc)<\/code><\/td><td>\u30b0\u30eb\u30fc\u30d7\u5316\uff08abc\u306b\u30de\u30c3\u30c1\uff09<\/td><\/tr><tr><td><code>(?:abc)<\/code><\/td><td>\u975e\u30ad\u30e3\u30d7\u30c1\u30e3\u30b0\u30eb\u30fc\u30d7\uff08\u30de\u30c3\u30c1\u3059\u308b\u304c\u7d50\u679c\u306b\u542b\u307e\u308c\u306a\u3044\uff09<\/td><\/tr><tr><td><code>a|b<\/code><\/td><td>a\u307e\u305f\u306fb\u306b\u30de\u30c3\u30c1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong>\u30a8\u30b9\u30b1\u30fc\u30d7\u6587\u5b57<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30d1\u30bf\u30fc\u30f3<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>\\<\/code><\/td><td>\u7279\u6b8a\u6587\u5b57\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\uff08\u4f8b: <code>\\.<\/code>\u306f\u30d4\u30ea\u30aa\u30c9\u6587\u5b57\uff09<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">7. <strong>\u7279\u6b8a\u6587\u5b57<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30d1\u30bf\u30fc\u30f3<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>[abc]<\/code><\/td><td>a\u3001b\u3001c\u306e\u3044\u305a\u308c\u304b1\u6587\u5b57<\/td><\/tr><tr><td><code>[^abc]<\/code><\/td><td>a\u3001b\u3001c\u4ee5\u5916\u306e\u4efb\u610f\u306e1\u6587\u5b57<\/td><\/tr><tr><td><code>[a-z]<\/code><\/td><td>\u5c0f\u6587\u5b57\u306ea\u304b\u3089z\u307e\u3067\u306e\u3044\u305a\u308c\u304b1\u6587\u5b57<\/td><\/tr><tr><td><code>[A-Z]<\/code><\/td><td>\u5927\u6587\u5b57\u306eA\u304b\u3089Z\u307e\u3067\u306e\u3044\u305a\u308c\u304b1\u6587\u5b57<\/td><\/tr><tr><td><code>[0-9]<\/code><\/td><td>\u6570\u5b57\u306e0\u304b\u30899\u307e\u3067\u306e\u3044\u305a\u308c\u304b1\u6587\u5b57<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">8. <strong>\u30d5\u30e9\u30b0\uff08\u4fee\u98fe\u5b50\uff09<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30d5\u30e9\u30b0<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>i<\/code><\/td><td>\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u3092\u533a\u5225\u3057\u306a\u3044<\/td><\/tr><tr><td><code>m<\/code><\/td><td>\u8907\u6570\u884c\u30e2\u30fc\u30c9\uff08<code>^<\/code>\u3068<code>$<\/code>\u304c\u5404\u884c\u306e\u5148\u982d\u30fb\u672b\u5c3e\u306b\u30de\u30c3\u30c1\uff09<\/td><\/tr><tr><td><code>s<\/code><\/td><td>\u30c9\u30c3\u30c8\u304c\u6539\u884c\u306b\u3082\u30de\u30c3\u30c1<\/td><\/tr><tr><td><code>u<\/code><\/td><td>UTF-8\u30e2\u30fc\u30c9\u3092\u6709\u52b9\u306b\u3059\u308b<\/td><\/tr><tr><td><code>x<\/code><\/td><td>\u30d1\u30bf\u30fc\u30f3\u5185\u306e\u7a7a\u767d\u3092\u7121\u8996\uff08\u53ef\u8aad\u6027\u5411\u4e0a\uff09<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">9. <strong>PHP\u3067\u306e\u6b63\u898f\u8868\u73fe\u95a2\u6570<\/strong><\/h3>\n\n\n\n<p>PHP\u306b\u306f\u6b63\u898f\u8868\u73fe\u3092\u6271\u3046\u305f\u3081\u306e\u95a2\u6570\u304c\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u95a2\u6570\u540d<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>preg_match()<\/code><\/td><td>\u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d<\/td><\/tr><tr><td><code>preg_match_all()<\/code><\/td><td>\u5168\u3066\u306e\u4e00\u81f4\u3092\u53d6\u5f97<\/td><\/tr><tr><td><code>preg_replace()<\/code><\/td><td>\u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3057\u305f\u90e8\u5206\u3092\u7f6e\u63db<\/td><\/tr><tr><td><code>preg_split()<\/code><\/td><td>\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u3066\u6587\u5b57\u5217\u3092\u5206\u5272<\/td><\/tr><tr><td><code>preg_grep()<\/code><\/td><td>\u914d\u5217\u306e\u4e2d\u304b\u3089\u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3059\u308b\u8981\u7d20\u3092\u53d6\u5f97<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">10. <strong>\u5b9f\u4f8b<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u691c\u8a3c<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  $pattern = \"\/^&#91;a-zA-Z0-9._%+-]+@&#91;a-zA-Z0-9.-]+\\.&#91;a-zA-Z]{2,}$\/\";\n  $email = \"example@test.com\";\n  if (preg_match($pattern, $email)) {\n      echo \"\u6709\u52b9\u306a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3067\u3059\u3002\";\n  } else {\n      echo \"\u7121\u52b9\u306a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3067\u3059\u3002\";\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u96fb\u8a71\u756a\u53f7\u306e\u691c\u8a3c<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  $pattern = \"\/^\\d{3}-\\d{4}-\\d{4}$\/\";\n  $phone = \"090-1234-5678\";\n  if (preg_match($pattern, $phone)) {\n      echo \"\u6709\u52b9\u306a\u96fb\u8a71\u756a\u53f7\u3067\u3059\u3002\";\n  } else {\n      echo \"\u7121\u52b9\u306a\u96fb\u8a71\u756a\u53f7\u3067\u3059\u3002\";\n  }<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u3001\u3055\u3089\u306b\u5177\u4f53\u7684\u306a\u4f8b\u3084\u7528\u9014\u306b\u3064\u3044\u3066\u3082\u304a\u7b54\u3048\u3067\u304d\u307e\u3059\uff01<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u3067\u4f7f\u7528\u3055\u308c\u308b\u6b63\u898f\u8868\u73fe\uff08\u6b63\u898f\u8868\u73fe\u30d1\u30bf\u30fc\u30f3\uff09\u306f\u3001\u6587\u5b57\u5217\u64cd\u4f5c\u3084\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u30f3\u30b0\u306b\u975e\u5e38\u306b\u4fbf\u5229\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001PHP\u3067\u3088\u304f\u4f7f\u308f\u308c\u308b\u6b63\u898f\u8868\u73fe\u306e\u4e00\u89a7\u3068\u305d\u306e\u8aac\u660e\u3092\u7c21\u5358\u306b\u307e\u3068\u3081\u307e\u3057\u305f\u3002 1. \u57fa\u672c\u69cb\u6587 2. \u6587\u5b57\u30af\u30e9\u30b9 \u30d1\u30bf\u30fc\u30f3 \u8aac\u660e . \u4efb\u610f\u306e1\u6587\u5b57\uff08\u6539\u884c\u3092\u9664\u304f\uff09 \\d \u6570\u5b57\uff080\uff5e9\uff09 \\D \u6570\u5b57\u4ee5\u5916\u306e\u6587\u5b57 \\w \u82f1\u6570\u5b57\u307e\u305f\u306f\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\uff08[a-zA-Z0-9_]\uff09 \\W \u82f1\u6570\u5b57\u307e\u305f\u306f\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u4ee5\u5916  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":46,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,3],"tags":[],"class_list":["post-139","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-3"],"_links":{"self":[{"href":"https:\/\/pclife-qa.com\/index.php?rest_route=\/wp\/v2\/posts\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pclife-qa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pclife-qa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pclife-qa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pclife-qa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=139"}],"version-history":[{"count":2,"href":"https:\/\/pclife-qa.com\/index.php?rest_route=\/wp\/v2\/posts\/139\/revisions"}],"predecessor-version":[{"id":141,"href":"https:\/\/pclife-qa.com\/index.php?rest_route=\/wp\/v2\/posts\/139\/revisions\/141"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pclife-qa.com\/index.php?rest_route=\/wp\/v2\/media\/46"}],"wp:attachment":[{"href":"https:\/\/pclife-qa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pclife-qa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pclife-qa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}