{"id":46,"date":"2024-09-10T10:45:59","date_gmt":"2024-09-10T02:45:59","guid":{"rendered":"http:\/\/47.121.202.229\/?p=46"},"modified":"2024-11-28T14:04:49","modified_gmt":"2024-11-28T06:04:49","slug":"php%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"http:\/\/47.121.202.229\/?p=46","title":{"rendered":"PHP\u5b66\u4e60\u7b14\u8bb0"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">0x00    \u57fa\u672c<\/h2>\n\n\n\n<p>php\u6587\u4ef6\u901a\u5e38\u5305\u542bHTML CSS JS\u7684\u4ee3\u7801\uff0c\u4f46\u662fphp\u4ee3\u7801\u5199\u5728HTML CSS JS\u6587\u4ef6\u91cc\u4e0d\u80fd\u7f16\u8bd1\u8fd0\u884c<\/p>\n\n\n\n<p>php\u4ee3\u7801\u5757\u7528&lt;?php      ?&gt;\u6765\u5305\u88f9\uff0c\u6bcf\u884c\u4ee3\u7801\u4ee5\u5206\u53f7\u5206\u9694<\/p>\n\n\n\n<p>php\u7684\u4e24\u79cd\u8f93\u51fa\u65b9\u6cd5\uff1aecho \u80fd\u8f93\u51fa\u4e00\u4e2a\u4ee5\u4e0a\u5b57\u7b26\u4e32\uff0c\u7528\u82f1\u6587\u9017\u53f7\u9694\u5f00<\/p>\n\n\n\n<p>print\u53ea\u80fd\u8f93\u51fa\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u6709\u8fd4\u56de\u503c\uff0c\u59cb\u7ec8\u8fd4\u56de1<\/p>\n\n\n\n<p>php\u7684\u6ce8\u91ca\uff1a\/\/\u5355\u884c\u6ce8\u91ca   #\u5355\u884c\u6ce8\u91ca    \/*   \u591a\u884c\u6ce8\u91ca    *\/  <\/p>\n\n\n\n<p> \/**  \uff08\u591a\u884c\u6ce8\u91ca\uff0c\u6bcf\u884c\u524d\u52a0\u4e00\u4e2a*\uff09      *\/<\/p>\n\n\n\n<p>\u7528$\u5b9a\u4e49\u53d8\u91cf  \u53d8\u91cf\u4e0e$\u7ed1\u5b9a \u53d8\u91cf\u53ef\u4ee5\u4ee5\u5b57\u6bcd\u3001\u4e0b\u5212\u7ebf\u5f00\u5934\uff0c\u4e0d\u80fd\u4ee5\u6570\u5b57\u5f00\u5934\uff1b\u53d8\u91cf\u540d\u53ea\u80fd\u5305\u542b\u6570\u5b57 \u5b57\u6bcd \u5b57\u7b26 \u4e0b\u5212\u7ebf\uff0c\u4e0d\u80fd\u5305\u62ec\u7a7a\u683c   \u53d8\u91cf\u540d\u5bf9\u5927\u5c0f\u5199\u654f\u611f<\/p>\n\n\n\n<p>\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u3001\u7c7b\u3001\u5173\u952e\u8bcd\u5bf9\u5927\u5c0f\u5199\u4e0d\u654f\u611f\uff01\uff01\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">0x01  \u8f93\u5165\u8f93\u51fa<\/h2>\n\n\n\n<p>\u63a5\u6536\u7528\u6237\u8f93\u5165\uff1a<\/p>\n\n\n\n<p>$input=readline(&#8220;\u4e2d\u95f4\u53ef\u4ee5\u6dfb\u52a0\u6587\u5b57\u4f5c\u4e3a\u63d0\u793a&#8221;);<\/p>\n\n\n\n<p>$input=fgets(STDIN);<\/p>\n\n\n\n<p>\u5c06\u8f93\u5165\u7684\u5185\u5bb9\u8f93\u51fa<\/p>\n\n\n\n<p>echo &#8220;\u60a8\u8f93\u5165\u7684\u5185\u5bb9\u662f\uff1a &#8221; . ($input);<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">0x02   \u57fa\u672c<\/h2>\n\n\n\n<p>\u7528var_dump()\u4f1a\u8fd4\u56de\u53d8\u91cf\u7684\u6570\u636e\u7c7b\u578b  \u548c \u503c \uff08\u6574\u6570\u6570\u636e\u7c7b\u578b\u5c06\u4f1a\u4ee5\u5341\u8fdb\u5236\u6253\u5370\u51fa\uff09<\/p>\n\n\n\n<p>gettype()\u53ef\u4ee5\u76f4\u63a5\u8fd4\u56de\u4e00\u4e2a\u53d8\u91cf\u7684\u6570\u636e\u7c7b\u578b<\/p>\n\n\n\n<p>php\u4e2d\u5355\u5f15\u53f7\u4e0e\u53cc\u5f15\u53f7\u7684\u533a\u522b\uff1a\u201c\u53cc\u5f15\u53f7\u5185\u53ef\u4ee5\u76f4\u63a5\u5199\u53d8\u91cf\uff0c\u80fd\u88ab\u7f16\u8bd1\u51fa\u6765\u201d<\/p>\n\n\n\n<p>\u2018\u5355\u5f15\u53f7\u91cc\u4e0d\u80fd\u76f4\u63a5\u5199\u53d8\u91cf\u2019<\/p>\n\n\n\n<p>php\u4e2d\u53ef\u4ee5\u7528\u5341\u8fdb\u5236 \u5341\u516d\u8fdb\u5236\uff08\u524d\u7f00\u4e3a0x\u5f00\u5934\uff09 \u516b\u8fdb\u5236\uff08\u524d\u7f00\u4e3a0\u5f00\u5934\uff09\u4e09\u79cd\u683c\u5f0f\u6765\u89c4\u5b9a\u6574\u6570<\/p>\n\n\n\n<p>php\u4e2d\u6d6e\u70b9\u6570\u662f\u6709\u5c0f\u6570\u70b9\u7684\u6570\u5b57\u6216\u6307\u6570\u5f62\u5f0f\u7684\u6570\u5b57<\/p>\n\n\n\n<p>php\u4e2d\u5e03\u5c14\u503c true false<\/p>\n\n\n\n<p>\u6570\u7ec4  \u5206\u4e3a\u4e00\u7ef4\u6570\u7ec4\u4e0e\u591a\u7ef4\u6570\u7ec4.\u6570\u7ec4\u5b9a\u4e49\u65b9\u5f0f\u53ef\u4ee5\u7528arry()\u6216\u76f4\u63a5\u7528[]<\/p>\n\n\n\n<p>$car=arry(&#8220;volvo&#8221;,&#8221;BMW&#8221;,&#8221;SAAB&#8221;);<\/p>\n\n\n\n<p>$car=[&#8220;volvo&#8221;,&#8221;BMW&#8221;,&#8221;SAAB&#8221;];<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">0x03   EOF\u529f\u80fd<\/h2>\n\n\n\n<p>EOF\u8bed\u53e5  \u7528\u6765\u5305\u542b\u591a\u884c\u5b57\u7b26\u4e32  \u7684\u529f\u80fd  \uff08EOF\u53ea\u662f\u4e00\u4e2a\u6807\u8bc6\u7b26\uff0c\u53ef\u4ee5\u4e3a\u4efb\u610f\u5b57\u7b26\uff0c\u53ea\u8981\u4fdd\u8bc1\u524d\u540e\u76f8\u540c\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$name=\"runoob\";\n$a=&nbsp;<em>&lt;&lt;&lt;EOF\n&nbsp; &nbsp; &nbsp; &nbsp; \"abc\"$name\n&nbsp; &nbsp; &nbsp; &nbsp; \"123\"\nEOF<\/em>;\n<em>\/\/ \u7ed3\u675f\u9700\u8981\u72ec\u7acb\u4e00\u884c\u4e14\u524d\u540e\u4e0d\u80fd\u7a7a\u683c<\/em>\necho&nbsp;$a;\n?&gt;<\/code><\/pre>\n\n\n\n<p>\u5f00\u59cb\u6807\u8bc6\u53ef\u4ee5\u4e0d\u5e26\u5f15\u53f7\u6216\u5e26\u5355\u53cc\u5f15\u53f7\uff0c\u4e0d\u5e26\u5f15\u53f7\u4e0e\u5e26\u53cc\u5f15\u53f7\u6548\u679c\u4e00\u81f4\uff0c\u89e3\u91ca\u5185\u5d4c\u7684\u53d8\u91cf\u548c\u8f6c\u4e49\u7b26\u53f7\uff0c\u5e26\u5355\u5f15\u53f7\u5219\u4e0d\u89e3\u91ca\u5185\u5d4c\u7684\u53d8\u91cf\u548c\u8f6c\u4e49\u7b26\u53f7<\/p>\n\n\n\n<p>EOF\u4e2d\uff0c\u53d8\u91cf\u4e0d\u9700\u8981\u7528\u8fde\u63a5\u7b26 . \u6216 , \u6765\u62fc\u63a5<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">0x04   \u5e38\u91cf<\/h2>\n\n\n\n<p>php\u53ef\u4ee5\u7528const \u548cdefine()\u51fd\u6570\u6765\u5b9a\u4e49\u5e38\u91cf<\/p>\n\n\n\n<p>\u5e38\u91cf\u662f\u5168\u5c40\u7684\uff0c\u5728\u811a\u672c\u4efb\u4f55\u5730\u65b9\u90fd\u53ef\u4ee5\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bool define ( string $name , mixed $value &#91;, bool $case_insensitive = false ] )\n<\/code><\/pre>\n\n\n\n<p>\u7b2c\u4e09\u4e2a\u53c2\u6570\u4e0d\u7528\u7ba1\uff0c\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u7528\u6765\u786e\u5b9a\u8fd9\u4e2a\u5e38\u91cf \u5927\u5c0f\u5199\u654f\u611f\u4e0d\u654f\u611f\u7684<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/ \u533a\u5206\u5927\u5c0f\u5199\u7684\u5e38\u91cf\u540d\ndefine(\"GREETING\", \"\u6b22\u8fce\u8bbf\u95ee Dufufu \u7684\u535a\u5ba2\");\necho GREETING;    \/\/ \u8f93\u51fa \"\u6b22\u8fce\u8bbf\u95ee Dufufu \u7684\u535a\u5ba2\"\necho '&lt;br&gt;';\necho greeting;   \/\/ \u8f93\u51fa \"greeting\"\uff0c\u4f46\u662f\u6709\u8b66\u544a\u4fe1\u606f\uff0c\u8868\u793a\u8be5\u5e38\u91cf\u672a\u5b9a\u4e49\n?&gt;<\/code><\/pre>\n\n\n\n<p>const \u5173\u952e\u5b57\u5b9a\u4e49\u5e38\u91cf<\/p>\n\n\n\n<p> const CONSTANT_NAME = &#8220;value&#8221;;<\/p>\n\n\n\n<p>php\u4e2d\u8fd8\u50a8\u5b58\u5728\u4e00\u4e9b\u9884\u5b9a\u4e49\u5e38\u91cf \u5217\u4e3e\u4e00\u4e9b<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>PHP_VERSION<\/code>\uff1a\u5f53\u524d PHP \u89e3\u6790\u5668\u7684\u7248\u672c\u3002<\/li>\n\n\n\n<li><code>PHP_OS<\/code>\uff1a\u670d\u52a1\u5668\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002<\/li>\n\n\n\n<li><code>PHP_INT_MAX<\/code>\uff1a\u6700\u5927\u7684\u6574\u6570\u503c\u3002<\/li>\n\n\n\n<li><code>E_ERROR<\/code>\u3001<code>E_WARNING<\/code>\u3001<code>E_PARSE<\/code>&nbsp;\u7b49\uff1a\u9519\u8bef\u62a5\u544a\u7ea7\u522b<\/li>\n<\/ul>\n\n\n\n<p>php7\u7248\u672c\u4ee5\u4e0a \u5e38\u91cf\u4e5f\u53ef\u4ee5\u662f\u6570\u7ec4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define(\"FRUITS\", &#91;<br>\"Apple\",<br>\"Banana\",<br>\"Orange\"<br>]);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">0x05  \u5b57\u7b26\u4e32\u76f8\u5173<\/h2>\n\n\n\n<p>php\u4e2d \u53ea\u6709\u4e00\u4e2a\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26  \u5e76\u7f6e\u8fd0\u7b97\u7b26  .<\/p>\n\n\n\n<p>.  \u53ef\u4ee5\u628a\u4e24\u4e2a\u5b57\u7b26\u4e32\u503c\u8fde\u63a5\u8d77\u6765<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$txt1=\"Hello&nbsp;world!\";\n$txt2=\"What&nbsp;a&nbsp;nice&nbsp;day!\";\necho&nbsp;$txt1&nbsp;.&nbsp;\"&nbsp;\"&nbsp;.&nbsp;$txt2;\n?&gt;<\/code><\/pre>\n\n\n\n<p>php\u4e2d\u5bf9\u5b57\u7b26\u4e32\u7684\u51fd\u6570\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">strlen()<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\necho&nbsp;strlen(\"Hello&nbsp;world!\");\n?&gt;<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u4ee3\u7801\u5c06\u8fd4\u56de12<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">strpos()<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\necho&nbsp;strpos(\"Hello&nbsp;world!\",\"world\");\n?&gt;<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u4ee3\u7801\u8fd4\u56de6 \u4e4b\u6240\u4ee5\u662f6\u4e0d\u662f7 \u662f\u56e0\u4e3a\u7b2c\u4e00\u4e2a\u5b57\u7b26\u4e0b\u6807\u662f0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">0x06 \u591a\u7ef4\u6570\u7ec4<\/h2>\n\n\n\n<p>\u8bed\u6cd5\u683c\u5f0f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/&nbsp;\u4e8c\u7ef4\u6570\u7ec4:\n$cars&nbsp;=&nbsp;array\n(\n&nbsp;&nbsp;&nbsp;&nbsp;array(\"Volvo\",100,96),\n&nbsp;&nbsp;&nbsp;&nbsp;array(\"BMW\",60,59),\n&nbsp;&nbsp;&nbsp;&nbsp;array(\"Toyota\",110,100)\n);\nprint_r($cars);\n?&gt;<\/code><\/pre>\n\n\n\n<p>\u6307\u5b9a\u952e\u7684\u4e8c\u7ef4\u6570\u7ec4<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/47.121.202.229\/wp-content\/uploads\/2024\/09\/image.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"940\" data-original=\"http:\/\/47.121.202.229\/wp-content\/uploads\/2024\/09\/image.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-186\"  sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">0x07  date()\u51fd\u6570<\/h2>\n\n\n\n<p>\u628a\u65f6\u95f4\u6233\u683c\u5f0f\u5316\u4e3a\u53ef\u8bfb\u6027\u66f4\u597d\u7684\u65e5\u671f\u548c\u65f6\u95f4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>string date ( string $format &#91;, int $timestamp ] )<\/code><\/pre>\n\n\n\n<p>format:\u5fc5\u987b\u3002\u89c4\u5b9a\u65f6\u95f4\u6233\u7684\u683c\u5f0f<\/p>\n\n\n\n<p>timestamp:\u53ef\u9009\u3002\u89c4\u5b9a\u65f6\u95f4\u6233\u3002\u9ed8\u8ba4\u662f\u5f53\u524d\u7684\u65e5\u671f\u548c\u65f6\u95f4<\/p>\n","protected":false},"excerpt":{"rendered":"<p>0x00 \u57fa\u672c php\u6587\u4ef6\u901a\u5e38\u5305\u542bHTML CSS JS\u7684\u4ee3\u7801\uff0c\u4f46\u662fphp\u4ee3\u7801\u5199\u5728HTML CSS JS\u6587\u4ef6\u91cc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":47,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-46","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"http:\/\/47.121.202.229\/index.php?rest_route=\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/47.121.202.229\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/47.121.202.229\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/47.121.202.229\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/47.121.202.229\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=46"}],"version-history":[{"count":6,"href":"http:\/\/47.121.202.229\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":189,"href":"http:\/\/47.121.202.229\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions\/189"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/47.121.202.229\/index.php?rest_route=\/wp\/v2\/media\/47"}],"wp:attachment":[{"href":"http:\/\/47.121.202.229\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/47.121.202.229\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/47.121.202.229\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}