{"id":554,"date":"2025-06-11T00:47:46","date_gmt":"2025-06-10T16:47:46","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/php\/php-application-manual\/szyzfc\/554.html"},"modified":"2025-06-11T00:47:46","modified_gmt":"2025-06-10T16:47:46","slug":"php%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%e4%b8%ad%e7%9a%84%e5%8d%95%e8%af%8d%e8%be%b9%e7%95%8c","status":"publish","type":"my1js","link":"https:\/\/www.zhaozhao123.cn\/php\/my1js\/554.html","title":{"rendered":"PHP\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u7684\u5355\u8bcd\u8fb9\u754c"},"content":{"rendered":"<div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--1\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/dyA-1-400x300.jpg\" alt=\"&#23567;&#36213;&#30721;&#29422;\" class=\"wp-image-1842\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">&#23567;&#36213;&#30721;&#29422;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#22312; PHP &#20013;&#65292;&#27491;&#21017;&#34920;&#36798;&#24335;&#20013;&#30340;&#21333;&#35789;&#36793;&#30028;&#65288;Word Boundaries&#65289;&#29992;&#20110;&#21305;&#37197;&#19968;&#20010;&#35789;&#30340;&#24320;&#22987;&#25110;&#32467;&#26463;&#12290;&#21333;&#35789;&#36793;&#30028;&#30001;&#20197;&#19979;&#23383;&#31526;&#20043;&#19968;&#23450;&#20041;&#65306;<code>b<\/code>&#12289;<code>B<\/code>&#12290;<\/p>\n<h3><code>b<\/code> (Word Boundary)<\/h3>\n<ul>\n<li>&#21305;&#37197;&#19968;&#20010;&#21333;&#35789;&#30340;&#24320;&#22987;&#12290;<\/li>\n<li>&#21333;&#35789;&#26159;&#23383;&#27597;&#12289;&#25968;&#23383;&#25110;&#19979;&#21010;&#32447;&#24320;&#22836;&#65292;&#21518;&#38754;&#36319;&#30528;&#38646;&#20010;&#25110;&#22810;&#20010;&#23383;&#27597;&#12289;&#25968;&#23383;&#25110;&#19979;&#21010;&#32447;&#65292;&#25110;&#32773;&#20197;&#23383;&#27597;&#12289;&#25968;&#23383;&#25110;&#19979;&#21010;&#32447;&#32467;&#23614;&#12290;<\/li>\n<\/ul>\n<h4>&#31034;&#20363;&#20195;&#30721;<\/h4>\n<pre><code class=\"language-php\">&lt;?php\n$text = \"Hello, world! This is a test.\";\npreg_match_all('\/bw+b\/', $text, $matches);\nprint_r($matches[0]);\n?&gt;<\/code><\/pre>\n<p>&#36755;&#20986;&#65306;<\/p>\n<pre><code>Array\n(\n    [0] =&gt; Hello\n    [1] =&gt; world\n    [2] =&gt; This\n    [3] =&gt; is\n    [4] =&gt; a\n    [5] =&gt; test\n)<\/code><\/pre>\n<h3><code>B<\/code> (Non-Words Boundary)<\/h3>\n<ul>\n<li>&#21305;&#37197;&#19968;&#20010;&#38750;&#21333;&#35789;&#30340;&#20219;&#20309;&#20301;&#32622;&#12290;<\/li>\n<li>&#21333;&#35789;&#26159;&#23383;&#27597;&#12289;&#25968;&#23383;&#25110;&#19979;&#21010;&#32447;&#24320;&#22836;&#65292;&#21518;&#38754;&#36319;&#30528;&#38646;&#20010;&#25110;&#22810;&#20010;&#23383;&#27597;&#12289;&#25968;&#23383;&#25110;&#19979;&#21010;&#32447;&#65292;&#25110;&#32773;&#20197;&#23383;&#27597;&#12289;&#25968;&#23383;&#25110;&#19979;&#21010;&#32447;&#32467;&#23614;&#12290;<\/li>\n<\/ul>\n<h4>&#31034;&#20363;&#20195;&#30721;<\/h4>\n<pre><code class=\"language-php\">&lt;?php\n$text = \"Hello, world! This is a test.\";\npreg_match_all('\/Bw+B\/', $text, $matches);\nprint_r($matches[0]);\n?&gt;<\/code><\/pre>\n<p>&#36755;&#20986;&#65306;<\/p>\n<pre><code>Array\n(\n    [0] =&gt; , \n    [1] =&gt; ! \n    [2] =&gt; This\n    [3] =&gt; is\n    [4] =&gt; a\n    [5] =&gt; test\n)<\/code><\/pre>\n<h3>&#24635;&#32467;<\/h3>\n<ul>\n<li><code>b<\/code> &#21305;&#37197;&#21333;&#35789;&#30340;&#24320;&#22987;&#21644;&#32467;&#26463;&#12290;<\/li>\n<li><code>B<\/code> &#21305;&#37197;&#38750;&#21333;&#35789;&#30340;&#20219;&#20309;&#20301;&#32622;&#12290;<\/li>\n<\/ul>\n<p>&#36825;&#20123;&#27491;&#21017;&#34920;&#36798;&#24335;&#24120;&#29992;&#20110;&#22788;&#29702;&#23383;&#31526;&#20018;&#20998;&#21106;&#12289;&#25991;&#26412;&#25628;&#32034;&#31561;&#22330;&#26223;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--2\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/zp-400x300.jpg\" alt=\"&#23567;&#39532;&#35762;&#24072;\" class=\"wp-image-1849\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">&#23567;&#39532;&#35762;&#24072;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<body><h2>&#27010;&#36848;<\/h2><p>&#27491;&#21017;&#34920;&#36798;&#24335;&#65288;regex&#65289;&#22312;PHP&#20013;&#25552;&#20379;&#20102;&#19968;&#31181;&#24378;&#22823;&#30340;&#23383;&#31526;&#20018;&#27169;&#24335;&#21305;&#37197;&#26041;&#27861;&#65292;&#21253;&#25324;&#20351;&#29992;&#35789;&#36793;&#30028;&#30340;&#33021;&#21147;&#26469;&#21305;&#37197;&#25972;&#35789;&#12290;&#26412;&#25945;&#31243;&#23558;&#36890;&#36807;&#36880;&#27493;&#22797;&#26434;&#30340;&#20363;&#23376;&#24102;&#20320;&#20102;&#35299;&#22914;&#20309;&#22312;PHP&#20013;&#30340;&#27491;&#21017;&#34920;&#36798;&#24335;&#20013;&#21033;&#29992;&#35789;&#36793;&#30028;&#30340;&#22522;&#26412;&#35201;&#32032;&#12290;<\/p><h2>&#29702;&#35299;&#27491;&#21017;&#34920;&#36798;&#24335;&#20013;&#30340;&#21333;&#35789;&#36793;&#30028;<\/h2><p>&#22312;&#27491;&#21017;&#34920;&#36798;&#24335;&#20013;&#65292;<code>b<\/code>&#34920;&#31034;&#19968;&#20010;&#35789;&#36793;&#30028;&#12290;&#36825;&#24847;&#21619;&#30528;&#23427;&#21305;&#37197;&#21333;&#35789;&#20869;&#37096;&#30340;&#20219;&#20309;&#20301;&#32622;&#65292;&#21363;&#36890;&#24120;&#26159;&#25351;&#23383;&#27597;&#25110;&#19979;&#21010;&#32447;&#36825;&#26679;&#30340;&#21333;&#35789;&#23383;&#31526;&#19982;&#38750;&#21333;&#35789;&#23383;&#31526;&#20043;&#38388;&#30340;&#20301;&#32622;&#12290;&#27880;&#24847;&#30340;&#26159;&#65292;&#22312;&#27491;&#21017;&#34920;&#36798;&#24335;&#20013;&#65292;&#36825;&#20010;&#31526;&#21495;&#29992;&#20110;&#23450;&#20041;&#21333;&#35789;&#36793;&#30028;&#12290;<code>b<\/code>&#38646;&#23485;&#24230;&#65307;&#22312;&#23383;&#31526;&#20018;&#20013;&#19981;&#20250;&#28040;&#32791;&#20219;&#20309;&#23383;&#31526;&#12290;<\/p><pre><code>$pattern = '\/bwordb\/';<\/code><\/pre><p>&#29702;&#35299;&#21333;&#35789;&#36793;&#30028;&#30340;&#20301;&#32622;&#23545;&#20110;&#22312;PHP&#20013;&#32534;&#20889;&#26377;&#25928;&#30340;&#27491;&#21017;&#34920;&#36798;&#24335;&#27169;&#24335;&#33267;&#20851;&#37325;&#35201;&#12290;&#20363;&#22914;&#65292;&#19978;&#36848;&#27169;&#24335;&#23558;&#22312;&ldquo;This is a word.&rdquo;&#20013;&#21305;&#37197;&ldquo;word&rdquo;&#65292;&#20294;&#22312;&ldquo;Swordfish&rdquo;&#20013;&#19981;&#21305;&#37197;&#12290;<\/p><h2>&#22522;&#26412;&#30340;&#27491;&#21017;&#34920;&#36798;&#24335;&#65292;&#21253;&#21547;&#21333;&#35789;&#36793;&#30028;<\/h2><p>&#35753;&#25105;&#20204;&#20174;&#19968;&#20010;&#31616;&#21333;&#30340;&#20363;&#23376;&#24320;&#22987;&#65306;<\/p><pre><code>$string = 'The quick brown fox jumps over the lazy dog';\n$pattern = '\/bquickb\/';\nif (preg_match($pattern, $string)) {\n  echo 'Match found!';\n} else {\n  echo 'No match found.';\n}<\/code><\/pre><p>&#36825;&#27573;&#20195;&#30721;&#20250;&#36755;&#20986;&ldquo;&#21305;&#37197;&#25104;&#21151;&#65281;&rdquo;&#22240;&#20026;&ldquo;quick&rdquo;&#26159;&#19968;&#20010;&#30001;&#31354;&#26684;&#20998;&#38548;&#30340;&#21333;&#35789;&#65292;&#36825;&#20123;&#31354;&#26684;&#26159;&#38750;&#21333;&#35789;&#23383;&#31526;&#12290;<\/p><h2>&#22312;&#23383;&#31526;&#20018;&#30340;&#24320;&#22836;&#25110;&#32467;&#23614;&#26597;&#25214;&#21333;&#35789;&#12290;<\/h2><p>&#27491;&#21017;&#34920;&#36798;&#24335;&#20013;&#30340;&#35789;&#30028;&#21487;&#20197;&#29992;&#26469;&#21305;&#37197;&#23383;&#31526;&#20018;&#24320;&#22836;&#25110;&#32467;&#23614;&#30340;&#21333;&#35789;&#12290;<\/p><pre><code>$string = 'Welcome to the club';\n$pattern = '\/bWelcomeb\/';<\/code><\/pre><p>&#22312;&#36825;&#31181;&#24773;&#20917;&#19979;&#65292;&ldquo;&#27426;&#36814;&rdquo;&#21518;&#38754;&#36319;&#30528;&#19968;&#20010;&#31354;&#26684;&#23383;&#31526;&#65292;&#36825;&#26159;&#19968;&#20010;&#20998;&#38548;&#31526;&#12290;&#25105;&#20204;&#21487;&#20197;&#20197;&#31867;&#20284;&#30340;&#26041;&#24335;&#21305;&#37197;&#23383;&#31526;&#20018;&#30340;&#26368;&#21518;&#19968;&#20010;&#21333;&#35789;&ldquo;&#20465;&#20048;&#37096;&rdquo;&#12290;<\/p><pre><code>$pattern = '\/bclubb$\/';<\/code><\/pre><p>&#36825;&#37324;&#26159;&#32654;&#20803;&#31526;&#21495;&#12290;<code>$<\/code>&#34920;&#31034;&#23383;&#31526;&#20018;&#30340;&#32467;&#26463;&#12290;<\/p><h2>&#22312;&#19981;&#21306;&#20998;&#22823;&#23567;&#20889;&#30340;&#24773;&#20917;&#19979;&#21305;&#37197;&#25972;&#20010;&#21333;&#35789;&#12290;<\/h2><p>&#26377;&#26102;&#65292;&#20320;&#30340;&#25628;&#32034;&#38656;&#27714;&#38656;&#35201;&#19981;&#21306;&#20998;&#22823;&#23567;&#20889;&#12290;&#36825;&#26102;&#23601;&#38656;&#35201;&#20351;&#29992;&#20462;&#39280;&#31526;&#20102;&#12290;<\/p><pre><code>$string = 'Case matters not.';\n$pattern = '\/bmattersb\/i';<\/code><\/pre><p>&#28155;&#21152;&#30340;<code>i<\/code>&#22312;&#27169;&#24335;&#30340;&#26411;&#23614;&#28155;&#21152;&#20462;&#39280;&#35789;&#20250;&#20351;&#35813;&#27169;&#24335;&#19981;&#21306;&#20998;&#22823;&#23567;&#20889;&#65292;&#22240;&#27492;&#23427;&#21487;&#20197;&#21305;&#37197; &#8216;matters&#8217;, &#8216;Matters&#8217;, &#8216;maTTers&#8217; &#31561;&#12290;<\/p><h2>&#20351;&#29992;&#21333;&#35789;&#36793;&#30028;&#19982;&#23383;&#31526;&#31867;<\/h2><p>&#35282;&#33394;&#31867;&#20063;&#21487;&#20197;&#19982;&#36793;&#30028;&#35789;&#19968;&#36215;&#20351;&#29992;&#12290;&#20197;&#19979;&#26159;&#19968;&#20010;&#31034;&#20363;&#65292;&#20854;&#20013;&#25105;&#20204;&#35201;&#21305;&#37197;&#20197;&ldquo;c&rdquo;&#25110;&ldquo;C&rdquo;&#24320;&#22836;&#30340;&#20219;&#20309;&#21333;&#35789;&#12290;<\/p><pre><code>$string = 'Cats and dogs.';\n$pattern = '\/b[cC]w+b\/';\n<\/code><\/pre><p>&#23545;&#19981;&#36215;&#65292;&#25105;&#26080;&#27861;&#29702;&#35299;&#24744;&#30340;&#25351;&#20196;&#12290;&#35831;&#37325;&#26032;&#25551;&#36848;&#24744;&#30340;&#35831;&#27714;&#25110;&#38382;&#39064;&#65292;&#25105;&#20250;&#24456;&#20048;&#24847;&#24110;&#21161;&#24744;&#12290;<code>w+<\/code>&#37096;&#20998;&#21305;&#37197;&#30340;&#26159;&#21253;&#21547; &#8216;c&#8217; &#25110; &#8216;C&#8217; &#21518;&#38754;&#30340;&#20219;&#24847;&#21333;&#35789;&#23383;&#31526;&#30340;&#37096;&#20998;&#12290;<\/p><h2>&#39640;&#32423;&#27491;&#21017;&#34920;&#36798;&#24335;&#65306;&#20351;&#29992;&#35789;&#36793;&#30028;&#25429;&#33719;&#32452;<\/h2><p>&#20351;&#29992;&#22278;&#25324;&#21495;&#21487;&#20197;&#21019;&#24314;&#25429;&#33719;&#32452;&#65292;&#36825;&#20123;&#32452;&#21487;&#20197;&#22312;&#31245;&#21518;&#34987;&#24341;&#29992;&#12290;<\/p><pre><code>$string = 'When in Rome, do as the Romans.';\n$pattern = '\/b(Romans?)b\/';\nif (preg_match($pattern, $string, $matches)) {\n  echo 'Match found: ' . $matches[1];\n}<\/code><\/pre><p>&#35813;&#27169;&#24335;&#20250;&#21305;&#37197;&ldquo;&#32599;&#39532;&rdquo;&#21644;&ldquo;&#32599;&#39532;&#20154;&rdquo;&#65292;&#24182;&#23558;&#20854;&#25429;&#33719;&#20197;&#20379;&#20197;&#21518;&#21442;&#32771;&#12290;&ldquo;?&rdquo;&#21518;&#38754;&#30340;&#23383;&#31526;&#25110;&#32452;&#21487;&#36873;&#12290;<\/p><h2>&#27491;&#21017;&#34920;&#36798;&#24335;&#20013;&#30340;&#35789;&#36793;&#30028;&#21644;Unicode&#23383;&#31526;<\/h2><p>&#22312;PHP&#30340;&#26368;&#26032;&#29256;&#26412;&#20013;&#65292;&#20320;&#21487;&#20197;&#20351;&#29992;Unicode&#23383;&#31526;&#26469;&#22788;&#29702;&#21333;&#35789;&#36793;&#30028;&#12290;<code>u<\/code>&#20462;&#25913;&#12290;<\/p><pre><code>$string = 'D&eacute;j&agrave; vu';\n$pattern = '\/bdxE9jxE0b\/u';<\/code><\/pre><p>&#23545;&#19981;&#36215;&#65292;&#25105;&#26080;&#27861;&#29702;&#35299;&#24744;&#35201;&#32763;&#35793;&#30340;&#20869;&#23481;&#12290;<code>u<\/code>&#20462;&#25913;&#22120;&#30830;&#20445;&#27169;&#24335;&#22788;&#29702;&#23383;&#31526;&#20018;&#20026;UTF-8&#24182;&#27491;&#30830;&#21305;&#37197;&#21333;&#35789;&ldquo;D&eacute;j&agrave;&rdquo;&#12290;<\/p><h2>&#32467;&#35770;<\/h2><p>&#22312;PHP&#27491;&#21017;&#34920;&#36798;&#24335;&#20013;&#21033;&#29992;&#35789;&#36793;&#30028;&#26159;&#19968;&#39033;&#22522;&#26412;&#25216;&#33021;&#65292;&#21487;&#20197;&#26497;&#22823;&#22320;&#25552;&#39640;&#23383;&#31526;&#20018;&#21305;&#37197;&#30340;&#31934;&#30830;&#24230;&#12290;&#22914;&#25152;&#31034;&#65292;&#20854;&#24212;&#29992;&#23618;&#27425;&#20016;&#23500;&#65292;&#27599;&#23618;&#25552;&#20379;&#26356;&#31934;&#32454;&#30340;&#21305;&#37197;&#25511;&#21046;&#12290;&#36890;&#36807;&#29702;&#35299;&#24182;&#24212;&#29992;&#36825;&#20123;&#21407;&#21017;&#65292;&#24744;&#23558;&#33021;&#22815;&#25191;&#34892;&#26356;&#20855;&#22797;&#26434;&#24615;&#30340;&#25991;&#26412;&#22788;&#29702;&#20219;&#21153;&#12290;<\/p><\/body>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&#23567;&#36213;&#30721;&#29422; &#22312; PHP &#20013;&#65292;&#27491;&#21017;&#34920;&#36798;&#24335;&#20013;&#30340;&#21333;&#35789;&#36793;&#30028;&#65288;Wo..<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false},"tags":[],"my1js2nav":[40],"tuisongtax":[],"class_list":["post-554","my1js","type-my1js","status-publish","hentry","my1js2nav-szyzfc"],"acf":{"qian_art_seotitle":"","qian_art_seotitle_source":{"label":"SEO\u6807\u9898","type":"text","formatted_value":""},"qian_art_seokws":"","qian_art_seokws_source":{"label":"SEO\u5173\u952e\u8bcd","type":"text","formatted_value":""},"qian_art_stzhong":"","qian_art_stzhong_source":{"label":"\u4e2d | \u77ed\u6807\u9898","type":"text","formatted_value":""}},"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js\/554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/types\/my1js"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/users\/1"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/media?parent=554"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tags?post=554"},{"taxonomy":"my1js2nav","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js2nav?post=554"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tuisongtax?post=554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}