{"id":399,"date":"2025-06-10T19:51:57","date_gmt":"2025-06-10T11:51:57","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/php\/php-application-manual\/jcyy\/399.html"},"modified":"2025-06-10T19:51:57","modified_gmt":"2025-06-10T11:51:57","slug":"php-%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b%e5%8f%82%e8%80%83%e6%89%8b%e5%86%8c","status":"publish","type":"my1js","link":"https:\/\/www.zhaozhao123.cn\/php\/my1js\/399.html","title":{"rendered":"PHP \u6570\u636e\u7c7b\u578b\u53c2\u8003\u624b\u518c"},"content":{"rendered":"<p><body><\/p>\n<h2>&#20171;&#32461;<\/h2>\n<p>PHP &#26159;&#19968;&#31181;&#28789;&#27963;&#30340;&#35821;&#35328;&#65292;&#25317;&#26377;&#31616;&#21333;&#30340;&#25968;&#25454;&#31867;&#22411;&#31995;&#32479;&#12290;&#20102;&#35299;&#20854;&#22522;&#26412;&#21040;&#39640;&#32423;&#30340;&#25968;&#25454;&#31867;&#22411;&#23545;&#20110;&#32534;&#20889;&#26377;&#25928;&#19988;&#24378;&#22823;&#30340; PHP &#20195;&#30721;&#33267;&#20851;&#37325;&#35201;&#12290;&#36825;&#20221; cheat sheet &#23558;&#20316;&#20026;&#24555;&#36895;&#21442;&#32771;&#21644;&#25351;&#21335;&#65292;&#36890;&#36807;&#20195;&#30721;&#31034;&#20363;&#20171;&#32461; PHP &#20013;&#30340;&#21508;&#31181;&#25968;&#25454;&#31867;&#22411;&#12290;<\/p>\n<h2>&#22522;&#26412;&#30340;PHP&#25968;&#25454;&#31867;&#22411;&#12290;<\/h2>\n<p>PHP &#25903;&#25345;&#22235;&#31181;&#22522;&#26412;&#25968;&#25454;&#31867;&#22411;&#65306;<\/p>\n<p>&#23383;&#31526;&#20018;&#65306;&#30001;&#23383;&#31526;&#32452;&#25104;&#30340;&#24207;&#21015;&#65292;&#21487;&#20197;&#20351;&#29992;&#21333;&#24341;&#21495;&#25110;&#21452;&#24341;&#21495;&#26469;&#25351;&#23450;&#12290;<\/p>\n<p>&#28014;&#28857;&#25968;&#65306;&#24102;&#26377;&#23567;&#25968;&#28857;&#25110;&#25351;&#25968;&#24418;&#24335;&#30340;&#25968;&#23383;&#65288;&#20363;&#22914;&#65292;1.234 &#25110; 4E-10&#65289;&#12290;<\/p>\n<p>&#25972;&#25968;&#65306;PHP_INT_MIN &#21644; PHP_INT_MAX &#20043;&#38388;&#30340;&#38750;&#21313;&#36827;&#21046;&#25968;&#12290;<\/p>\n<p>&#24067;&#23572;&#31867;&#22411;&#21482;&#26377;&#20004;&#31181;&#20540;&#65306;<code>true<\/code>&#21734;&#65292;&#26159;&#30340;&#12290;<code>false<\/code>&#22909;&#30340;&#65292;&#35831;&#21457;&#36865;&#20320;&#38656;&#35201;&#32763;&#35793;&#30340;&#20869;&#23481;&#12290;<\/p>\n<p>&#19979;&#38754;&#26159;&#23637;&#31034;PHP&#22522;&#26412;&#25968;&#25454;&#31867;&#22411;&#22768;&#26126;&#30340;&#31034;&#20363;&#65306;<\/p>\n<pre><code>&lt;?php\n$boolean = TRUE; \/\/ A boolean\n$integer = 42; \/\/ An integer\n$float = 3.14; \/\/ A float\n$string = 'Hello, World!'; \/\/ A string\n?&gt;<\/code><\/pre>\n<h2>&#22797;&#21512;&#25968;&#25454;&#31867;&#22411;<\/h2>\n<p>PHP &#20063;&#21253;&#21547;&#20004;&#31181;&#22797;&#21512;&#25968;&#25454;&#31867;&#22411;&#65306;<\/p>\n<p>&#23545;&#35937;&#65306;&#31867;&#30340;&#19968;&#20010;&#23454;&#20363;&#65292;&#33021;&#22815;&#25345;&#26377;&#23646;&#24615;&#21644;&#26041;&#27861;&#12290;<\/p>\n<p>&#25968;&#32452;&#65306;&#26377;&#24207;&#30340;&#26144;&#23556;&#34920;&#65292;&#21487;&#20197;&#21253;&#21547;&#20854;&#20182;&#25968;&#32452;&#65292;&#20174;&#32780;&#24418;&#25104;&#22810;&#32500;&#25968;&#32452;&#12290;<\/p>\n<p>&#20197;&#19979;&#26159;&#19968;&#20123;&#25968;&#32452;&#21644;&#23545;&#35937;&#22768;&#26126;&#31034;&#20363;&#65306;<\/p>\n<pre><code>&lt;?php\n\/\/ Indexed array\n$array = array('Apple', 'Banana', 'Cherry');\n\n\/\/ Associative array\n$assocArray = array('color' =&gt; 'red', 'taste' =&gt; 'sweet');\n\n\/\/ Object creation using stdClass\n$object = new stdClass();\n$object-&gt;name = 'John';\n$object-&gt;age = 25;\n?&gt;<\/code><\/pre>\n<h2>&#29305;&#27530;&#25968;&#25454;&#31867;&#22411;<\/h2>\n<p>PHP&#36824;&#20855;&#26377;&#20004;&#31181;&#29305;&#27530;&#30340;&#25968;&#25454;&#31867;&#22411;&#65306;<\/p>\n<p>&#19968;&#20010;&#26410;&#36171;&#20540;&#30340;&#21464;&#37327;&#12290;<\/p>\n<p>&#36164;&#28304;&#65306;&#19968;&#20010;&#24341;&#29992;&#22806;&#37096;&#36164;&#28304;&#30340;&#29305;&#27530;&#21464;&#37327;&#12290;<\/p>\n<p>&#20197;&#19979;&#26159;&#36164;&#28304;&#21644;NULL&#25968;&#25454;&#31867;&#22411;&#30340;&#31034;&#20363;&#65306;<\/p>\n<pre><code>&lt;?php\n\/\/ Resource \n$resource = fopen('somefile.txt', 'r');\n\n\/\/ NULL\n$nullVar = NULL;\n?&gt;<\/code><\/pre>\n<h2>&#39764;&#26415;&#34920;&#28436;&#21644;&#27861;&#26415;&#25805;&#20316;<\/h2>\n<p>PHP &#33258;&#21160;&#36716;&#25442;&#25968;&#25454;&#31867;&#22411;&#65292;&#36825;&#31181;&#21151;&#33021;&#31216;&#20026;&#31867;&#22411;&#28151;&#32534;&#12290;&#20294;&#26159;&#65292;&#20063;&#21487;&#20197;&#26174;&#24335;&#22320;&#36827;&#34892;&#31867;&#22411;&#36716;&#25442;&#12290;&#19979;&#38754;&#26159;&#20004;&#31181;&#31034;&#20363;&#65306;<\/p>\n<pre><code>&lt;?php\n\/\/ Type Juggling\n$sum = '3' + 4; \/\/ $sum will be an integer (7)\n\n\/\/ Type Casting\n$sum = (int) '3' + 4; \/\/ $sum will be an integer (7)\n$bool = (bool) 1; \/\/ $bool will be a boolean (true)\n?&gt;<\/code><\/pre>\n<h2>&#39640;&#32423;PHP&#25968;&#25454;&#31867;&#22411;<\/h2>\n<p>&#22312;&#26356;&#39640;&#32423;&#30340;&#24212;&#29992;&#31243;&#24207;&#20013;&#65292;&#29702;&#35299;&#24120;&#37327;&#25968;&#25454;&#31867;&#22411;&#12289;stdClass&#21644;&#36845;&#20195;&#20266;&#25968;&#25454;&#31867;&#22411;&#26159;&#26377;&#30410;&#30340;&#12290;&#24120;&#37327;&#20801;&#35768;&#25351;&#23450;&#19981;&#21487;&#21464;&#20540;&#12290;stdClass &#26159;&#23545;&#35937;&#26410;&#22768;&#26126;&#65288;&#19981;&#26174;&#24335;&#36716;&#25442;&#20026;&#23545;&#35937;&#65289;&#26102;&#30340;&#23545;&#35937;&#40664;&#35748;&#31867;&#12290;Iterable &#26159;&#22312;PHP 7.1 &#20013;&#24341;&#20837;&#30340;&#19968;&#31181;&#20266;&#25968;&#25454;&#31867;&#22411;&#65292;&#20801;&#35768;&#23545;&#19968;&#32452;&#25968;&#25454;&#38598;&#36827;&#34892;&#20132;&#20114;&#25805;&#20316;&#12290;<\/p>\n<pre><code>&lt;?php\n\/\/ Constants\ndefine('MY_CONSTANT', 123);\n\n\/\/ stdClass objects\n$user = new stdClass();\n$user-&gt;name = 'Alice';\n\n\/\/ Iterable\nfunction printIterable(iterable $myIterable) {\n  foreach ($myIterable as $item) {\n    echo $item;\n  }\n}\n\n\/\/ Example usage\n$myArray = ['A', 'B', 'C'];\nprintIterable($myArray);\n?&gt;<\/code><\/pre>\n<h2>&#32467;&#35770;&#12290;<\/h2>\n<p>&#36825;&#20010;PHP&#25968;&#25454;&#31867;&#22411;&#36895;&#26597;&#34920;&#26088;&#22312;&#24110;&#21161;&#24744;&#24555;&#36895;&#19978;&#25163;PHP&#30340;&#26680;&#24515;&#25968;&#25454;&#31867;&#22411;&#12290;&#20316;&#20026;&#19968;&#31181;&#21160;&#24577;&#35821;&#35328;&#65292;PHP&#30340;&#23398;&#20064;&#26354;&#32447;&#30456;&#23545;&#24179;&#32531;&#65292;&#20294;&#23545;&#24213;&#23618;&#25968;&#25454;&#31867;&#22411;&#30340;&#28145;&#21051;&#29702;&#35299;&#23558;&#26174;&#33879;&#25552;&#39640;&#20195;&#30721;&#30340;&#28165;&#26224;&#24230;&#21644;&#25928;&#29575;&#12290;<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#20171;&#32461; PHP &#26159;&#19968;&#31181;&#28789;&#27963;&#30340;&#35821;&#35328;&#65292;&#25317;&#26377;&#31616;&#21333;&#30340;&#25968;&#25454;&#31867;&#038;#2..<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false},"tags":[],"my1js2nav":[38],"tuisongtax":[],"class_list":["post-399","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\/399","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=399"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tags?post=399"},{"taxonomy":"my1js2nav","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/my1js2nav?post=399"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/php\/wp-json\/wp\/v2\/tuisongtax?post=399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}