{"id":203,"date":"2020-11-09T16:01:09","date_gmt":"2020-11-09T16:01:09","guid":{"rendered":"http:\/\/robinluo.top\/?p=203"},"modified":"2020-11-10T01:31:03","modified_gmt":"2020-11-10T01:31:03","slug":"php-%e5%9f%ba%e7%a1%80","status":"publish","type":"post","link":"https:\/\/robinluo.top\/?p=203","title":{"rendered":"PHP \u57fa\u7840"},"content":{"rendered":"\n<p>PHP\u53d8\u91cf\u4ee5$<\/p>\n\n\n<p style=\"padding-left: 40px;\"><em>\u5b57\u7b26\u4e32\u6a21\u677f : $temp = &#8220;Hello , {$var1} !&#8221;;<\/em><\/p>\n\n\n<p>if\u8bed\u6cd5\uff1a<em><sub>(\u6ce8\uff1a\u662f elseif \u4e0d\u662felse if)<\/sub><\/em><\/p>\n\n\n<p style=\"padding-left: 40px;\"><em>if(true){<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>}elseif(false){<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>}else{<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>}<\/em><\/p>\n\n\n<p>while\u8bed\u6cd5\uff1a<\/p>\n\n\n<p style=\"padding-left: 40px;\"><em>while\uff08true\uff09{&nbsp;<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>}<\/em><\/p>\n\n\n<p>\u6570\u7ec4\u8bed\u6cd5\uff1a<\/p>\n\n\n<p style=\"padding-left: 40px;\"><del><em>array(key=&gt;value,key=&gt;value)<\/em><\/del><\/p>\n<p style=\"padding-left: 40px;\"><em>[key=&gt;value,key=&gt;value]&nbsp; <\/em>\/\/\u6620\u5c04\u7c7b\u6570\u7ec4<\/p>\n<p style=\"padding-left: 40px;\"><em>[value1,value2]&nbsp;<\/em> \/\/\u987a\u5e8f\u7c7b\u6570\u7ec4<\/p>\n<p style=\"padding-left: 40px;\"><em>count($array) <\/em>\/\/\u8fd4\u56de\u6570\u7ec4\u957f\u5ea6<\/p>\n\n\n<p>\u6570\u7ec4\u8fed\u4ee3:<\/p>\n\n\n<p style=\"padding-left: 40px;\"><em>foreach\uff08$array as $key =&gt; $value\uff09{<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>}<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>foreach ($array as $value){<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>}<\/em><\/p>\n\n\n<p>\u51fd\u6570:<\/p>\n\n\n<p style=\"padding-left: 40px;\"><em>function($variable){<\/em><\/p>\n<p style=\"padding-left: 80px;\"><em>return $value<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>}<\/em><\/p>\n\n\n<p>\u6a21\u5757: \u901a\u8fc7require\u5f15\u5165\u67d0\u4e2a\u6587\u4ef6 \u901a\u8fc7use \u5f15\u5165\u547d\u540d\u7a7a\u95f4<\/p>\n\n\n<p style=\"padding-left: 40px;\"><em>require &#8220;another.php&#8221;<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>use &#8220;\/Robin\/luo\/Another&#8221;<\/em><\/p>\n\n\n<p><p style=\"padding-left: 40px;\"> \u7c7b\uff1a<\/p>\n\n\n<p style=\"padding-left: 40px;\"><em>class Another {<\/em><\/p>\n<p style=\"padding-left: 80px;\"><em>public $property<\/em><\/p>\n<p style=\"padding-left: 80px;\"><em>public function __construct($property){<\/em><\/p>\n<p style=\"padding-left: 120px;\"><em>this-&gt;property = $property;<\/em><\/p>\n<p style=\"padding-left: 80px;\"><em>}<\/em><\/p>\n<p style=\"padding-left: 80px;\"><em>public function func($param){<\/em><\/p>\n<p style=\"padding-left: 120px;\"><em>return $value;<\/em><\/p>\n<p style=\"padding-left: 80px;\"><em>}<\/em><\/p>\n<p style=\"padding-left: 80px;\"><em>public static function func1(){<\/em><\/p>\n<p style=\"padding-left: 80px;\"><em>}<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>}<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>$object = new Another();<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>$object1 = new Another(1);<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>$object-&gt;property = 1;<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>$object-&gt;func(1);<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>Another::func1();<\/em><\/p>\n<p><\/p>\n\n\n<p>\u547d\u540d\u7a7a\u95f4\uff1a\u901a\u8fc7namespace \u5b9a\u4e49  \u7528\\\u8fdb\u884c\u89e3\u6790\u4e0d\u662fjava\u7684.<\/p>\n\n\n<p style=\"padding-left: 40px;\"><em>namespace Robin;<\/em><\/p>\n<p style=\"padding-left: 40px;\"><em>\\Robin\\luo::reading();<\/em><\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u53d8\u91cf\u4ee5$ \u5b57\u7b26\u4e32\u6a21\u677f : $temp = &#8220;Hello , {$var1} !&#8221;; if\u8bed\u6cd5\uff1a(\u6ce8\uff1a\u662f elseif \u4e0d\u662felse if) if(true){ }elseif(false){ }else{ } while\u8bed\u6cd5\uff1a while\uff08true\uff09{&nbsp; } \u6570\u7ec4\u8bed\u6cd5\uff1a array(key=&gt;value,key=&gt;value) [key=&gt;value,key=&gt;value]&nbsp; \/\/\u6620\u5c04\u7c7b\u6570\u7ec4 [value1,value2]&nbsp; \/\/\u987a\u5e8f\u7c7b\u6570\u7ec4 count($array) \/\/\u8fd4\u56de\u6570\u7ec4\u957f\u5ea6 \u6570\u7ec4\u8fed\u4ee3: foreach\uff08$array as $key =&gt; $value\uff09{ } foreach ($array as $value){ } \u51fd\u6570: function($variable){ return $value } \u6a21\u5757: \u901a\u8fc7require\u5f15\u5165\u67d0\u4e2a\u6587\u4ef6 \u901a\u8fc7use \u5f15\u5165\u547d\u540d\u7a7a\u95f4 require &#8220;another.php&#8221; use &#8220;\/Robin\/luo\/Another&#8221; \u7c7b\uff1a class [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/203"}],"collection":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=203"}],"version-history":[{"count":10,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/203\/revisions"}],"predecessor-version":[{"id":215,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/203\/revisions\/215"}],"wp:attachment":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}