{"id":469,"date":"2025-06-10T20:54:01","date_gmt":"2025-06-10T12:54:01","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/php\/php-application-manual\/jcyy\/469.html"},"modified":"2025-06-10T20:54:01","modified_gmt":"2025-06-10T12:54:01","slug":"%e5%a6%82%e4%bd%95%e4%bf%ae%e5%a4%8dphp%e9%80%9a%e7%9f%a5%ef%bc%9a%e6%9c%aa%e5%ae%9a%e4%b9%89%e7%9a%84%e5%8f%98%e9%87%8f","status":"publish","type":"my1js","link":"https:\/\/www.zhaozhao123.cn\/php\/my1js\/469.html","title":{"rendered":"\u5982\u4f55\u4fee\u590dPHP\u901a\u77e5\uff1a\u672a\u5b9a\u4e49\u7684\u53d8\u91cf"},"content":{"rendered":"<p><body><\/p>\n<h2>&#20171;&#32461;<\/h2>\n<p>&#36935;&#21040;PHP&#20013;&#30340;&ldquo;&#26410;&#23450;&#20041;&#21464;&#37327;&rdquo;&#35686;&#21578;&#26159;&#24456;&#24120;&#35265;&#30340;&#38382;&#39064;&#65292;&#24403;&#24320;&#21457;&#25110;&#32500;&#25252;PHP&#20195;&#30721;&#26102;&#20250;&#21457;&#29983;&#36825;&#31181;&#24773;&#20917;&#12290;&#36825;&#20010;&#35686;&#21578;&#26159;&#30001;PHP&#29983;&#25104;&#30340;&#65292;&#24403;&#24744;&#23581;&#35797;&#20351;&#29992;&#19968;&#20010;&#23578;&#26410;&#35774;&#32622;&#25110;&#23450;&#20041;&#30340;&#21464;&#37327;&#26102;&#65307;&#25442;&#21477;&#35805;&#35828;&#65292;&#22914;&#26524;&#35813;&#21464;&#37327;&#19981;&#23384;&#22312;&#25110;&#20174;&#26410;&#34987;&#36171;&#20540;&#12290;<\/p>\n<p>&ldquo;&#26410;&#23450;&#20041;&#21464;&#37327;&rdquo;&#30340;&#35686;&#21578;&#19981;&#26159;&#33268;&#21629;&#38169;&#35823;&#65292;&#19981;&#20250;&#38459;&#27490;&#33050;&#26412;&#36816;&#34892;&#12290;&#28982;&#32780;&#65292;&#23427;&#34920;&#26126;&#20102;&#32534;&#30721;&#23454;&#36341;&#30340;&#19981;&#36275;&#65292;&#21487;&#33021;&#20250;&#23548;&#33268;&#24212;&#29992;&#31243;&#24207;&#30340;&#34892;&#20026;&#19981;&#19968;&#33268;&#25110;&#20986;&#29616;bug&#12290;&#22240;&#27492;&#65292;&#29702;&#35299;&#36825;&#20010;&#35686;&#21578;&#30340;&#21407;&#22240;&#24182;&#23398;&#20064;&#22914;&#20309;&#27491;&#30830;&#20462;&#22797;&#38750;&#24120;&#37325;&#35201;&#12290;<\/p>\n<h2>&#29702;&#35299;PHP&#38169;&#35823;&#20449;&#24687;&#65288;Notice&#65289;<\/h2>\n<p>PHP &#30340;&#35686;&#21578;&#20449;&#24687;&#26159; PHP &#38169;&#35823;&#25253;&#21578;&#26426;&#21046;&#30340;&#32467;&#26524;&#12290;&#24403;&#20320;&#30475;&#21040;&#19968;&#20010;&#35686;&#21578;&#26102;&#65292;&#36890;&#24120;&#26159;&#22240;&#20026;&#20320;&#30340; PHP &#37197;&#32622;&#20013;&#30340;&#38169;&#35823;&#25253;&#21578;&#32423;&#21035;&#21253;&#25324;&#20102;&#23427;&#12290;<code>E_NOTICE<\/code>, which reports runtime notices. Notices are less severe than warnings (<code>E_WARNING<\/code>) &#21644;&#33268;&#21629;&#38169;&#35823;&#65288;<code>E_ERROR<\/code>&#23427;&#20204;&#20026;&#24320;&#21457;&#20154;&#21592;&#25552;&#20379;&#20102;&#20851;&#20110;&#20854;&#20195;&#30721;&#28508;&#22312;&#38382;&#39064;&#30340;&#37325;&#35201;&#25552;&#31034;&#12290;<\/p>\n<p>&#20026;&#20102;&#26242;&#26102;&#25233;&#21046;&#36825;&#20123;&#36890;&#30693;&#65292;&#19968;&#20123;&#24320;&#21457;&#32773;&#20351;&#29992;&#20102;&#36825;&#31181;&#26041;&#27861;&#12290;<code>error_reporting<\/code>&#21151;&#33021;&#65306;<\/p>\n<pre><code>error_reporting(E_ALL &amp; ~E_NOTICE);\n<\/code><\/pre>\n<p>&#34429;&#28982;&#36825;&#25513;&#30422;&#20102;&#35686;&#21578;&#65292;&#20294;&#23427;&#24182;&#27809;&#26377;&#35299;&#20915;&#26681;&#26412;&#38382;&#39064;&#65292;&#19981;&#24212;&#34987;&#35270;&#20026;&#35299;&#20915;&#26041;&#26696;&#12290;<\/p>\n<h2>&#26410;&#23450;&#20041;&#21464;&#37327;&#36890;&#30693;<\/h2>\n<p>&#24403;&#23581;&#35797;&#35775;&#38382;&#25110;&#25805;&#20316;&#23578;&#26410;&#23450;&#20041;&#30340;&#21464;&#37327;&#26102;&#65292;&#20250;&#20986;&#29616;&ldquo;&#26410;&#23450;&#20041;&#21464;&#37327;&rdquo;&#35686;&#21578;&#20449;&#24687;&#12290;&#20363;&#22914;&#65306;<\/p>\n<pre><code>$total = $count + 10;\n<\/code><\/pre>\n<p>&#22914;&#26524;<code>$count<\/code>&#23578;&#26410;&#35774;&#32622;&#20043;&#21069;&#65292;PHP &#20250;&#29983;&#25104;&#35686;&#21578;&#12290;<\/p>\n<h2>&#24120;&#35265;&#21407;&#22240;<\/h2>\n<p>&#21464;&#37327;&#21517;&#20013;&#30340;&#25340;&#20889;&#38169;&#35823;&#12290;2. &#22312;&#21464;&#37327;&#26410;&#23450;&#20041;&#25110;&#26410;&#32463;&#26816;&#26597;&#26159;&#21542;&#23384;&#22312;&#30340;&#24773;&#20917;&#19979;&#20351;&#29992;&#21464;&#37327;&#12290;3. &#19981;&#28385;&#36275;&#26465;&#20214;&#23601;&#35774;&#32622;&#21464;&#37327;&#65292;&#23548;&#33268;&#20195;&#30721;&#22359;&#27704;&#36828;&#19981;&#20250;&#36816;&#34892;&#12290;4. &#26410;&#27491;&#30830;&#25552;&#20132;&#25110;&#22788;&#29702;&#34920;&#21333;&#25968;&#25454;&#12290;5. &#38169;&#35823;&#30340;&#20989;&#25968;&#21442;&#25968;&#12290;<\/p>\n<h2>&#26368;&#20339;&#23454;&#36341;&#65306;&#35299;&#20915;&#26041;&#27861;<\/h2>\n<p>&#32780;&#19981;&#26159;&#27785;&#40664;&#36825;&#20123;&#35686;&#21578;&#65292;&#20320;&#24212;&#35813;&#27491;&#30830;&#22320;&#35299;&#20915;&#26681;&#26412;&#38382;&#39064;&#12290;&#20197;&#19979;&#26159;&#19968;&#20123;&#20851;&#20110;&#22914;&#20309;&#22788;&#29702;&#26410;&#23450;&#20041;&#21464;&#37327;&#35686;&#21578;&#30340;&#26368;&#20339;&#23454;&#36341;&#65306;<\/p>\n<h3>&#21021;&#22987;&#21270;&#21464;&#37327;<\/h3>\n<p>&#22312;&#20351;&#29992;&#21464;&#37327;&#20043;&#21069;&#65292;&#21153;&#24517;&#30830;&#20445;&#23427;&#24050;&#34987;&#21021;&#22987;&#21270;&#65306;<\/p>\n<pre><code>$count = 0;\n$total = $count + 10;\n<\/code><\/pre>\n<h3>&#20351;&#29992; isset() &#25110; empty()<\/h3>\n<p>&#26816;&#26597;&#21464;&#37327;&#26159;&#21542;&#23384;&#22312;&#20351;&#29992;<code>isset()<\/code>&#25110;&#32773;&#22914;&#26524;&#23427;&#26377;&#19968;&#20010;&#38750;&#31354;&#12289;&#38750;&#38646;&#30340;&#20540;&#20351;&#29992;<code>empty()<\/code>&#65306;<\/p>\n<pre><code>if (isset($count)) {\n    $total = $count + 10;\n} else {\n    $total = 10;\n}\n<\/code><\/pre>\n<h3>&#20351;&#29992;&#19977;&#20803;&#36816;&#31639;&#31526;&#25110;Null coalescing&#25805;&#20316;&#31526;&#12290;<\/h3>\n<p>&#20026;&#20102;&#31616;&#27905;&#30340;&#20195;&#30721;&#65292;&#20320;&#21487;&#20197;&#20351;&#29992;&#19977;&#20803;&#36816;&#31639;&#31526;&#25110;null coalescing&#36816;&#31639;&#31526;&#65306;<\/p>\n<pre><code>$total = (isset($count) ? $count : 0) + 10;\n\/\/ or with PHP 7+\n$total = ($count ?? 0) + 10;\n<\/code><\/pre>\n<h3>&#27491;&#30830;&#22788;&#29702;&#34920;&#21333;&#21644;&#35831;&#27714;&#21464;&#37327;<\/h3>\n<p>&#22312;&#23581;&#35797;&#20351;&#29992;&#35831;&#27714;&#21464;&#37327;&#20043;&#21069;&#65292;&#35831;&#21153;&#24517;&#26816;&#26597;&#23427;&#20204;&#26159;&#21542;&#23384;&#22312;&#65306;<\/p>\n<pre><code>$count = isset($_POST['count']) ? intval($_POST['count']) : 0;\n<\/code><\/pre>\n<h3>&#20351;&#29992;&#40664;&#35748;&#20989;&#25968;&#21442;&#25968;<\/h3>\n<p>&#22914;&#26524;&#19968;&#20010;&#20989;&#25968;&#38656;&#35201;&#19968;&#20010;&#21442;&#25968;&#65292;&#20294;&#36825;&#20010;&#21442;&#25968;&#21487;&#33021;&#27809;&#26377;&#25552;&#20379;&#65292;&#21487;&#20197;&#20026;&#35813;&#21442;&#25968;&#35774;&#32622;&#40664;&#35748;&#20540;&#65306;<\/p>\n<pre><code>function calculateTotal($count = 0) {\n    return $count + 10;\n}\n<\/code><\/pre>\n<h2>&#24320;&#21457;&#21644;&#29983;&#20135;&#29615;&#22659;<\/h2>\n<p>&#22312;&#24320;&#21457;&#29615;&#22659;&#20013;&#65292;&#35774;&#32622;&#38169;&#35823;&#25253;&#21578;&#21040;&#26368;&#39640;&#32423;&#21035;&#26159;&#26377;&#30410;&#30340;&#65292;&#21487;&#20197;&#36890;&#36807;&#20351;&#29992;&#20197;&#19979;&#20195;&#30721;&#26469;&#23454;&#29616;&#65306;<code>error_reporting(E_ALL)<\/code>&#35813;&#37197;&#32622;&#23558;&#30830;&#20445;&#25152;&#26377;&#28508;&#22312;&#38382;&#39064;&#22312;&#24320;&#21457;&#36807;&#31243;&#20013;&#37117;&#33021;&#34987;&#21457;&#29616;&#21644;&#35299;&#20915;&#12290;<\/p>\n<p>&#22312;&#29983;&#20135;&#29615;&#22659;&#20013;&#65292;&#36890;&#24120;&#20250;&#36890;&#36807;&#20351;&#29992;&#20195;&#30721;&#26469;&#23631;&#34109;&#29992;&#25143;&#30475;&#21040;&#30340;&#38169;&#35823;&#28040;&#24687;&#12290;<code>error_reporting(0)<\/code>&#22240;&#27492;&#65292;&#20320;&#24212;&#35813;&#22312;&#20869;&#37096;&#35760;&#24405;&#38169;&#35823;&#20449;&#24687;&#20197;&#20379;&#34892;&#25919;&#23457;&#26597;&#20351;&#29992;&#12290;&#36825;&#26679;&#21487;&#20197;&#36991;&#20813;&#35753;&#29992;&#25143;&#30475;&#21040;&#19981;&#38597;&#30340;&#38169;&#35823;&#28040;&#24687;&#65292;&#24182;&#25552;&#20379;&#19968;&#31181;&#30417;&#25511;&#21644;&#20462;&#22797;&#37325;&#22797;&#38382;&#39064;&#30340;&#26041;&#27861;&#12290;<\/p>\n<h2>&#32467;&#35770;&#12290;<\/h2>\n<p>&#22788;&#29702;PHP&#35686;&#21578;&#65292;&#22914;&ldquo;&#26410;&#23450;&#20041;&#21464;&#37327;&rdquo;&#65292;&#21487;&#33021;&#19968;&#24320;&#22987;&#20250;&#35753;&#20154;&#24863;&#21040;&#26377;&#20123;&#32321;&#29712;&#65292;&#20294;&#23427;&#24341;&#23548;&#20320;&#32534;&#20889;&#26356;&#21152;&#20581;&#22766;&#21644;&#21487;&#32500;&#25252;&#30340;&#20195;&#30721;&#12290;&#36890;&#36807;&#36981;&#24490;&#26412;&#25351;&#21335;&#20013;&#25552;&#21040;&#30340;&#26368;&#20339;&#23454;&#36341;&#65292;&#20320;&#21487;&#20197;&#30830;&#20445;PHP&#33050;&#26412;&#20013;&#30340;&#21464;&#37327;&#24635;&#26159;&#34987;&#23450;&#20041;&#65292;&#36825;&#26377;&#21161;&#20110;&#38450;&#27490;&#35768;&#22810;&#24120;&#35265;&#38382;&#39064;&#21644;&#38169;&#35823;&#12290;&#27492;&#22806;&#65292;&#20445;&#25345;&#19968;&#20010;&#24178;&#20928;&#30340;&#26085;&#24535;&#25991;&#20214;&#21487;&#20197;&#24110;&#21161;&#20320;&#26356;&#26089;&#22320;&#21457;&#29616;&#30495;&#23454;&#30340;&#38382;&#39064;&#65292;&#24182;&#20026;&#20320;&#30340;PHP&#24212;&#29992;&#31243;&#24207;&#26500;&#24314;&#26356;&#22909;&#30340;&#22522;&#30784;&#12290;<\/p>\n<p>&#26368;&#32456;&#65292;&#23545;&#38169;&#35823;&#28040;&#24687;&#30340;&#25935;&#38160;&#20851;&#27880;&#21644;&#20027;&#21160;&#35299;&#20915;&#23427;&#20204;&#30340;&#26041;&#27861;&#23558;&#25552;&#39640;&#24744;&#30340;Web&#24212;&#29992;&#31243;&#24207;&#30340;&#21487;&#38752;&#24615;&#21644;&#36136;&#37327;&#65292;&#20174;&#32780;&#20026;&#29992;&#25143;&#25552;&#20379;&#26356;&#22909;&#30340;&#29992;&#25143;&#20307;&#39564;&#12290;<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#20171;&#32461; &#36935;&#21040;PHP&#20013;&#30340;&ldquo;&#26410;&#23450;&#20041;&#21464;&#37327;&rdquo;&#35686;&#21578;&#26159;&#24456;&#24120;&#35265;&#038;#3034..<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false},"tags":[],"my1js2nav":[38],"tuisongtax":[],"class_list":["post-469","my1js","type-my1js","status-publish","hentry","my1js2nav-jcyy"],"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\/469","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=469"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tags?post=469"},{"taxonomy":"my1js2nav","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js2nav?post=469"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tuisongtax?post=469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}