{"id":151,"date":"2025-06-19T20:09:53","date_gmt":"2025-06-19T12:09:53","guid":{"rendered":"http:\/\/101.201.119.158\/?p=151"},"modified":"2025-06-19T21:13:42","modified_gmt":"2025-06-19T13:13:42","slug":"php%e7%89%b9%e6%ae%8a%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"http:\/\/101.201.119.158\/?p=151","title":{"rendered":"PHP\u7279\u6b8a\u51fd\u6570"},"content":{"rendered":"\n<p>(\u57fa\u672c\u4e0a\u662f\u6839\u636eshow\u4e0a\u9762\u6574\u7406\u7684\uff0c\u8fd8\u6709\u4e00\u8d77\u5176\u4ed6\u4e0a\u9762\u7684)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">intval<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>echo boolval(intval('a'))?'true':'false'; \/\/false<br>echo boolval(intval('a', 16) === 10) ? 'true' : 'false'; \/\/true 'a'\u4ee3\u8868\u9700\u8981\u8f6c\u6362\u4e3a\u6574\u6570\u7684\u53d8\u91cf 16\u4ee3\u8868\u8f6c\u6362\u65f6\u4f7f\u7528\u7684\u8fdb\u5236\uff0c\u9ed8\u8ba4\u503c\u4e3a 10\uff08\u5341\u8fdb\u5236\uff09\u3002\u5408\u6cd5\u8303\u56f4\u662f 2 \u5230 36<\/pre>\n\n\n\n<p><code>intval()<\/code> \u662f PHP \u4e2d\u7684\u4e00\u4e2a\u5185\u7f6e\u51fd\u6570\uff0c\u5176\u4e3b\u8981\u529f\u80fd\u662f\u5c06\u53d8\u91cf\u8f6c\u6362\u4e3a\u6574\u6570\u7c7b\u578b\uff0c\u5982\u679c\u8f6c\u6362\u5931\u8d25\uff0c\u5c31\u4f1a\u8fd4\u56de0\uff0c\u4e0d\u8fc7\u8fd9\u4e2a\u51fd\u6570\u5982\u679c\u5305\u542b\u7684\u662f\u6570\u7ec4\uff0c\u53ea\u8981\u6570\u7ec4\u91cc\u9762\u5b58\u5728\u503c\uff0c\u5219\u8fd4\u56de1\uff0c\u53cd\u4e4b\uff0c\u8fd4\u56de0\uff0c\u5b57\u7b26\u4e32\u8f6c\u6362\u89c4\u5219\uff1a\u4ece\u5f00\u5934\u63d0\u53d6\u6570\u5b57\uff0c\u9047\u975e\u6570\u5b57\u505c\u6b62\uff08\u5982 <code>\"1a\"<\/code> \u2192 1\uff0c<code>\"a\"<\/code> \u2192 0\uff09\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">preg_match<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>$num = 0x12306;<br>if (preg_match(\"\/[0-9]\/\", $num)){<br> &nbsp;  die(\"no no no!\");<br>} \/\/no no no!<\/pre>\n\n\n\n<p>preg_match\u51fd\u6570\u662f\u6b63\u5219\u5339\u914d\uff0c\u5339\u914d\/\u3010\u53d8\u91cf\u3011\/\uff0c\u5982\u679c\u6b63\u597d\u5339\u914d\uff0c\u5219\u8fd4\u56de1\uff0c\u8fdb\u5165\u4e0b\u9762\u7684\u6761\u4ef6<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6b63\u5219\u8868\u8fbe\u5f0f\u4fee\u9970\u7b26<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">i <br>\u4e0d\u533a\u5206(ignore)\u5927\u5c0f\u5199<br>m<br>\u591a(more)\u884c\u5339\u914d<br>\u82e5\u5b58\u5728\u6362\u884c\\n\u5e76\u4e14\u6709\u5f00\u59cb^\u6216\u7ed3\u675f$\u7b26\u7684\u60c5\u51b5\u4e0b\uff0c<br>\u5c06\u4ee5\u6362\u884c\u4e3a\u5206\u9694\u7b26\uff0c\u9010\u884c\u8fdb\u884c\u5339\u914d<br>$str = \"abc\\nabc\";<br>$preg = \"\/^abc$\/m\";<br>preg_match($preg, $str,$matchs);<br>\u8fd9\u6837\u5176\u5b9e\u662f\u7b26\u5408\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\uff0c\u56e0\u4e3a\u5339\u914d\u7684\u65f6\u5019 \u5148\u662f\u5339\u914d\u6362\u884c\u7b26\u524d\u9762\u7684\uff0c\u63a5\u7740\u5339\u914d\u6362\u884c\u7b26\u540e\u9762\u7684\uff0c\u4e24\u4e2a\u90fd\u662fabc\u6240\u4ee5\u53ef\u4ee5\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u3002<br>s<br>\u7279\u6b8a\u5b57\u7b26\u5706\u70b9 . \u4e2d\u5305\u542b\u6362\u884c\u7b26<br>\u9ed8\u8ba4\u7684\u5706\u70b9 . \u662f\u5339\u914d\u9664\u6362\u884c\u7b26 \\n \u4e4b\u5916\u7684\u4efb\u4f55\u5355\u5b57\u7b26\uff0c\u52a0\u4e0as\u4e4b\u540e, .\u5305\u542b\u6362\u884c\u7b26<br>$str = \"abggab\\nacbs\";<br>$preg = \"\/b.\/s\";<br>preg_match_all($preg, $str,$matchs);<br>\u8fd9\u6837\u5339\u914d\u5230\u7684\u6709\u4e09\u4e2a bg b\\n bs<br>A<br>\u5f3a\u5236\u4ece\u76ee\u6807\u5b57\u7b26\u4e32\u5f00\u5934\u5339\u914d;<br>D<br>\u5982\u679c\u4f7f\u7528$\u9650\u5236\u7ed3\u5c3e\u5b57\u7b26,\u5219\u4e0d\u5141\u8bb8\u7ed3\u5c3e\u6709\u6362\u884c; <br>e<br>\u914d\u5408\u51fd\u6570preg_replace()\u4f7f\u7528, \u53ef\u4ee5\u628a\u5339\u914d\u6765\u7684\u5b57\u7b26\u4e32\u5f53\u4f5c\u6b63\u5219\u8868\u8fbe\u5f0f\u6267\u884c; \u5b58\u5728\u4e25\u91cd\u5b89\u5168\u6f0f\u6d1e\uff08\u5982\u547d\u4ee4\u6ce8\u5165\uff09\uff0cPHP 7.0 \u540e\u5df2\u79fb\u9664\u3002<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">===\u4e0e==<\/h3>\n\n\n\n<p>===\u662f\u5f3a\u7b49\u4e8e\uff0c\u9700\u8981\u7c7b\u578b\u548c\u6570\u503c\u90fd\u76f8\u7b49\u4e8e\uff0c==\u5219\u662f\u5f31\u7b49\u4e8e\uff0c\u4f1a\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\uff0c\u6570\u503c\u76f8\u7b49\u5c31\u884c\uff0c\u4f8b\u59821a==1\uff0c0==\u4efb\u610f\u5b57\u7b26<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>echo boolval(123===123)?'true':'false';  \/\/ \u8f93\u51fa\uff1atrue<br>echo boolval(0==='abc')?'true':'false'; &nbsp; \/\/ \u8f93\u51fa\uff1afalse<br>echo boolval(0=='a')?'true':'false'; &nbsp; &nbsp;  \/\/ \u8f93\u51fa\uff1atrue<br>echo boolval(1=='1a')?'true':'false'; &nbsp; &nbsp; \/\/ \u8f93\u51fa\uff1atrue<br>?&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">MD5\u4e0esha<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">if (md5($_POST['a']) === md5($_POST['b']))<br>echo $flag;<br>&lt;?php<br>$a = [];<br>$b = [];<br>echo boolval(md5($a)==md5($b))?'true':'false'; \/\/\u4f1a\u62a5\u9519\uff0c\u8fd4\u56defalse<\/pre>\n\n\n\n<p>md5 \u5f31\u7c7b\u578b\u6bd4\u8f83\u53ef\u4ee5\u76f4\u63a5\u6570\u7ec4\u7ed5\u8fc7\uff0c\u5176\u7ed3\u679c\u90fd\u4f1a\u8f6c\u6362\u4e3a null,sha\u4e5f\u7c7b\u4f3c<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">&amp;<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e00\uff1a\u5f15\u7528\u4f20\u9012<\/h3>\n\n\n\n<p>\u4ed6\u5e76\u4e0d\u662f\u6307\u9488\u7684\u610f\u601d\uff0c\u800c\u662f\u4e0d\u540c\u7684\u540d\u5b57\u8bbf\u95ee\u540c\u4e00\u4e2a\u53d8\u91cf\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">function increment(&amp;$num) {<br> &nbsp;  $num++;<br>}<br>$a = 5;<br>increment($a);<br>echo $a; \/\/ \u8f93\u51fa 6\uff08\u51fd\u6570\u76f4\u63a5\u4fee\u6539\u4e86\u539f\u59cb\u53d8\u91cf\uff09<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e8c:\u5f15\u7528\u8fd4\u56de<\/h3>\n\n\n\n<p>\u51fd\u6570\u53ef\u4ee5\u901a\u8fc7 <code>&amp;<\/code> \u8fd4\u56de\u53d8\u91cf\u7684\u5f15\u7528\uff0c\u800c\u975e\u503c\u7684\u526f\u672c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">function &amp;getArray() {<br> &nbsp;  static $arr = [1, 2, 3];<br> &nbsp;  return $arr;<br>}<br>\u200b<br>$ref = &amp;getArray();<br>$ref[] = 4;<br>echo implode(',', getArray()); \/\/ \u8f93\u51fa 1,2,3,4<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e09\uff1aand\u8fde\u63a5\u7b26<\/h3>\n\n\n\n<p>\u8fd9\u91cc\u63d2\u5165\u4e00\u70b9\uff0c= &gt; and<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u5143\u8fd0\u7b97\u7b26<\/h2>\n\n\n\n<p>(expr1) ? (expr2):(expr3)\u3002\u5982\u679c expr1 \u4e3a true\uff0c\u5219\u6267\u884c expr2\uff1b\u5426\u5219\uff0c\u6267\u884c expr3\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">array_push<\/h2>\n\n\n\n<p>\u5411\u6570\u7ec4\u5c3e\u90e8\u63d2\u5165\u4e00\u4e2a\u6216\u591a\u4e2a\u5143\u7d20\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">rand<\/h2>\n\n\n\n<p>\u751f\u6210\u968f\u673a\u6570\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">in_array<\/h2>\n\n\n\n<p>in_array($a,$b):\u641c\u7d22\u6570\u7ec4\u4e2d\u662f\u5426\u5b58\u5728\u6307\u5b9a\u7684\u503c\u3002\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u8981\u641c\u7d22\u7684\u503c\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u88ab\u641c\u7d22\u7684\u6570\u7ec4\u3002<\/p>\n\n\n\n<p>\u7ed5\u8fc7 in_array ()\uff1a\u5f53\u6ca1\u6709\u6307\u5b9a\u7b2c\u4e09\u4e2a\u53c2\u6570\u7684\u65f6\u5019\uff0cin_array \u5c31\u76f8\u5f53\u4e8e ==\uff0c\u5f31\u7c7b\u578b\u5bf9\u6bd4\u3002<\/p>\n\n\n\n<p>\u8865\u5145<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">in_array($needle, $haystack, $strict=false) \u4e2d\uff0c\u82e5 $strict \u4e3a false\uff0c\u4f7f\u7528\u5f31\u7b49\u4e8e\uff08==\uff09\u6bd4\u8f83\uff1b\u82e5\u4e3a true\uff0c\u4f7f\u7528\u5f3a\u7b49\u4e8e\uff08===\uff09\u3002<br>\u7ed5\u8fc7\u573a\u666f\uff1a\u5982 in_array('1', [1]) \u4e3a true\uff08\u5f31\u7c7b\u578b\u5339\u914d\uff09\uff0cin_array('1', [1], true) \u4e3a false\u3002<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">file_put_conntent (filename, data)\uff1a<\/h2>\n\n\n\n<p>filename\u662f\u8981\u5199\u5165\u540d\u5b57\u4e3adata\u6587\u4ef6\u7684\u5185\u5bb9<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">is_numeric<\/h2>\n\n\n\n<p>\u7528\u4e8e\u68c0\u6d4b\u53d8\u91cf\u662f\u5426\u4e3a\u6570\u5b57\u6216\u6570\u5b57\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53cd\u5c04\u7c7b<\/h2>\n\n\n\n<p>\u53cd\u5c04\u7c7b\uff08Reflection Classes\uff09\u662f PHP \u5185\u7f6e\u7684\u4e00\u7ec4\u7c7b\uff0c\u7528\u4e8e\u5b9e\u73b0\u53cd\u5c04\u529f\u80fd\uff0c\u5b83\u4eec\u63d0\u4f9b\u4e86\u5bf9\u7c7b\u3001\u65b9\u6cd5\u3001\u5c5e\u6027\u3001\u53c2\u6570\u7b49\u7684\u8be6\u7ec6\u4fe1\u606f\u8fdb\u884c introspection\uff08\u5185\u7701\uff09\u7684\u80fd\u529b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f5c\u7528<\/h3>\n\n\n\n<p>\u83b7\u53d6\u7c7b\u7684\u5b9a\u4e49\u4fe1\u606f\uff0c\u4f8b\u5982\u7c7b\u7684\u5c5e\u6027\u3001\u65b9\u6cd5\u3001\u5e38\u91cf\u7b49\u3002 \u52a8\u6001\u8c03\u7528\u7c7b\u7684\u65b9\u6cd5\u3002 \u4fee\u6539\u7c7b\u7684\u5c5e\u6027\u3002 \u68c0\u67e5\u51fd\u6570\u548c\u65b9\u6cd5\u7684\u53c2\u6570\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e38\u89c1\u7684\u7c7b<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"> ReflectionClass\uff1a\u7528\u4e8e\u83b7\u53d6\u7c7b\u7684\u8be6\u7ec6\u4fe1\u606f\u3002 <br> ReflectionMethod\uff1a\u7528\u4e8e\u83b7\u53d6\u65b9\u6cd5\u7684\u8be6\u7ec6\u4fe1\u606f\u3002 <br> ReflectionProperty\uff1a\u7528\u4e8e\u83b7\u53d6\u5c5e\u6027\u7684\u8be6\u7ec6\u4fe1\u606f\u3002 <br> ReflectionFunction\uff1a\u7528\u4e8e\u83b7\u53d6\u51fd\u6570\u7684\u8be6\u7ec6\u4fe1\u606f\u3002 <br> ReflectionParameter\uff1a\u7528\u4e8e\u83b7\u53d6\u65b9\u6cd5\u6216\u51fd\u6570\u53c2\u6570\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\u8d77\u4e00\u4e2a\u6817\u5b50<br>&lt;?php<br>class MyClass {<br>private $privateProp = 'private';<br>protected $protectedProp = 'protected';<br>}<br>$class = new \\ReflectionClass('MyClass');<br>$properties = $class-&gt;getProperties();<br>foreach ($properties as $property) {<br> &nbsp;  $name = $property-&gt;getName();<br> &nbsp;  $value = $property-&gt;getValue(new MyClass());<br> &nbsp;  echo \"$name: $value\\n\";<br>} \/\/<br>privateProp: private<br>protectedProp: protected<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">substr<\/h2>\n\n\n\n<p>substr($a,$b)\uff1a\u622a\u53d6\uff0c\u4ece\u5b57\u7b26\u4e32$a\u91cc\u9762\u622a\u53d6$b\u4f4d\u5b57\u7b26<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">call_user_func<\/h2>\n\n\n\n<p>call_user_func($a,$b)\uff1a\u8c03\u7528\u51fd\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u88ab\u8c03\u7528\u7684\u51fd\u6570\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u88ab\u8c03\u7528\u51fd\u6570\u6240\u9700\u7684\u53c2\u6570<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u6817\u5b50<br>&lt;?php<br>\/\/ \u793a\u4f8b1\uff1a\u8c03\u7528\u666e\u901a\u51fd\u6570<br>function aaa($a,$b) {<br> &nbsp;  echo $a*$b;<br>}<br>\/\/ \u76f4\u63a5\u8c03\u7528<br>echo aaa(1,2) . \"\\n\"; \/\/2<br>\/\/ \u901a\u8fc7 call_user_func \u8c03\u7528<br>echo call_user_func(\"aaa\", 1,2); \/\/2<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">hex2bin()<\/h2>\n\n\n\n<p>\u5c06\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u8f6c\u5316\u4e3a ASCII \u7801\u5b57\u7b26\uff08hex2bin () \u662f PHP \u4e2d\u7684\u4e00\u4e2a\u5185\u7f6e\u51fd\u6570\uff0c\u7528\u4e8e\u5c06\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u8fd4\u56de\u503c\uff1a\u6210\u529f\u65f6\u8fd4\u56de\u8f6c\u6362\u540e\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff1b\u5982\u679c\u8f93\u5165\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u65e0\u6548\uff0c\u51fd\u6570\u8fd4\u56de false\u3002\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u5fc5\u987b\u662f\u5076\u6570\uff0c\u5426\u5219 hex2bin () \u4f1a\u8fd4\u56de false\uff09<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53d8\u91cf\u8986\u76d6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u6982\u5ff5<\/h3>\n\n\n\n<p>\u53d8\u91cf\u8986\u76d6\u6f0f\u6d1e\u662f\u6307\u81ea\u5b9a\u4e49\u7684\u53c2\u6570\u66ff\u6362\u539f\u6709\u53d8\u91cf\u503c\u7684\u60c5\u51b5\uff0c\u5982$$\u4f7f\u7528\u4e0d\u5f53\uff0cextract\u51fd\u6570\u4f7f\u7528\u4e0d\u5f53\uff0cparse_str() \u51fd\u6570\u4f7f\u7528\u4e0d\u5f53\uff0cimport_request_variables() \u4f7f\u7528\u4e0d\u5f53\uff0c\u5f00\u542f\u4e86\u5168\u5c40\u53d8\u91cf\u6ce8\u518c\u7b49\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5168\u5c40\u53d8\u91cf\u5bfc\u81f4\u7684\u53d8\u91cf\u8986\u76d6<\/h3>\n\n\n\n<p>\u6f0f\u6d1e\u7b80\u4ecb\uff1a<\/p>\n\n\n\n<p>\u5f53register_globals\u5168\u5c40\u53d8\u91cf\u8bbe\u7f6e\u5f00\u542f\u65f6\uff0c\u4f20\u9012\u8fc7\u6765\u7684\u503c\u4f1a\u88ab\u76f4\u63a5\u6ce8\u518c\u4e3a\u5168\u5c40\u53d8\u91cf\u800c\u4f7f\u7528\uff0c\u8fd9\u4f1a\u9020\u6210\u5168\u5c40\u53d8\u91cf\u8986\u76d6 \u3002<\/p>\n\n\n\n<p>register_globals\u5168\u5c40\u53d8\u91cf\u8bbe\u7f6e\uff0c \u5728PHP5.3\u4e4b\u524d\u9ed8\u8ba4\u5f00\u542f\uff0c PHP5.3\u9ed8\u8ba4\u5173\u95ed \uff0cPHP5.6\u4ee5\u540e\u5df2\u7ecf\u88ab\u79fb\u9664 \u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>$num=0;<br>if ($num){<br> echo \"flag{this is flag}\";<br>}<br>?&gt; <br>\/\/payload: http:\/\/xx.xx.xx.xx\/test.php?num=1<br>\/\/result: flag{this is flag}<br>\/\/\u89e3\u6790\uff1a\u7531\u4e8e\u6211\u4eec\u4f7f\u7528\u7684\u662f\u4f4e\u7248\u672c\u7684PHP\uff0c\u9ed8\u8ba4\u5f00\u542f\u4e86\u5168\u5c40\u53d8\u91cf\uff0c\u5f53\u6211\u4eec\u4f20\u5165num\u7684\u65f6\u5019\uff0cPHP\u4f1a\u76f4\u63a5\u5c06\u4f20\u5165\u7684\u53c2\u6570\u5b9a\u4e49\u4e3a\u5168\u5c40\u53d8\u91cf\uff0c\u5bfc\u81f4\u53d8\u91cf\u8986\u76d6\u3002<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">$$\u52a8\u6001\u53d8\u91cf\u8986\u76d6<\/h3>\n\n\n\n<p>PHP\u52a8\u6001\u53d8\u91cf\u662f\u6307\u4e00\u4e2a\u53d8\u91cf\u540d\u7684\u53d8\u91cf\u540d\u53ef\u4ee5\u52a8\u6001\u7684\u8bbe\u7f6e\u548c\u4f7f\u7528\uff0c\u4e00\u4e2a\u53d8\u91cf\u83b7\u53d6\u53e6\u4e00\u4e2a\u53d8\u91cf\u7684\u503c\u4f5c\u4e3a\u8fd9\u4e2a\u53d8\u91cf\u7684\u53d8\u91cf\u540d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>$bar= \"a\";<br>$foo=\"bar\";<br>$world=\"foo\";<br>$hello=\"world\";<br>$a=\"hello\";<br>\u200b<br>echo $a; &nbsp; &nbsp; &nbsp;  \/\/ hello<br>echo $$a; &nbsp; &nbsp; &nbsp; \/\/ world<br>echo $$$a; &nbsp; &nbsp;  \/\/ foo<br>echo $$$$a; &nbsp; &nbsp; \/\/ bar<br>echo $$$$$a; &nbsp;  \/\/ a<br>echo $$$$$$a; &nbsp; \/\/ hello<br>echo $$$$$$$a;  \/\/ world<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">extract()\u51fd\u6570\u53d8\u91cf\u8986\u76d6<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">\u5b9a\u4e49\uff1aextract() \u51fd\u6570\u4ece\u6570\u7ec4\u4e2d\u5c06\u53d8\u91cf\u5bfc\u5165\u5230\u5f53\u524d\u7684\u7b26\u53f7\u8868\u3002\u8be5\u51fd\u6570\u4f7f\u7528\u6570\u7ec4\u952e\u540d\u4f5c\u4e3a\u53d8\u91cf\u540d\uff0c\u4f7f\u7528\u6570\u7ec4\u952e\u503c\u4f5c\u4e3a\u53d8\u91cf\u503c\u3002\u9488\u5bf9\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\uff0c\u5c06\u5728\u5f53\u524d\u7b26\u53f7\u8868\u4e2d\u521b\u5efa\u5bf9\u5e94\u7684\u4e00\u4e2a\u53d8\u91cf\uff0c\u8fd4\u56de\u6210\u529f\u8bbe\u7f6e\u7684\u53d8\u91cf\u6570\u76ee\u3002<br>\u8bed\u6cd5\uff1aextract(array,extract_rules,prefix)<br>    \/\/array:\u5fc5\u987b\uff0c\u89c4\u5b9a\u7528\u4e8e\u51c6\u6362\u7684\u6570\u7ec4<br>  \/\/extract_rules\uff1a\u53ef\u9009,\u51fd\u6570\u5c06\u68c0\u67e5\u6bcf\u4e2a\u952e\u540d\u662f\u5426\u4e3a\u5408\u6cd5\u7684\u53d8\u91cf\u540d\uff0c\u540c\u65f6\u4e5f\u68c0\u67e5\u548c\u7b26\u53f7\u8868\u4e2d\u5df2\u5b58\u5728\u7684\u53d8\u91cf\u540d\u662f\u5426\u51b2\u7a81\u3002\u5bf9\u4e0d\u5408\u6cd5\u548c\u51b2\u7a81\u7684\u952e\u540d\u7684\u5904\u7406\u5c06\u6839\u636e\u6b64\u53c2\u6570\u51b3\u5b9a\u3002\u9ed8\u8ba4\u8bbe\u7f6eEXTR_OVERWRITE\uff0c\u6709\u51b2\u7a81\u5219\u8986\u76d6\u3002<br>  \/\/prefix:\u8be5\u53c2\u6570\u89c4\u5b9a\u4e86\u524d\u7f00\u3002\u524d\u7f00\u548c\u6570\u7ec4\u952e\u540d\u4e4b\u95f4\u4f1a\u81ea\u52a8\u52a0\u4e0a\u4e00\u4e2a\u4e0b\u5212\u7ebf\uff0c\u53ef\u9009\u3002<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>$a = \"Original\";<br>$my_array = array(\"a\" =&gt; \"Cat\", \"b\" =&gt; \"Dog\", \"c\" =&gt; \"Horse\");<br>extract($my_array);<br>echo \"\\$a = $a; \\$b = $b; \\$c = $c; \";<br>?&gt;<br>\/\/result: $a = Cat; $b = Dog; $c = Horse; <\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">parse_str\u51fd\u6570\u53d8\u91cf\u8986\u76d6<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">\u8bed\u6cd5\uff1aparse_str(string,array)<br>\u5b9a\u4e49\uff1aparse_str() \u51fd\u6570\u628a\u67e5\u8be2\u5b57\u7b26\u4e32\u89e3\u6790\u5230\u53d8\u91cf\u4e2d\u3002\u5982\u679c\u672a\u8bbe\u7f6e array \u53c2\u6570\uff0c\u7531\u8be5\u51fd\u6570\u8bbe\u7f6e\u7684\u53d8\u91cf\u5c06\u8986\u76d6\u5df2\u5b58\u5728\u7684\u540c\u540d\u53d8\u91cf\u3002<br>\u6ce8\u91ca\uff1aphp.ini \u6587\u4ef6\u4e2d\u7684 magic_quotes_gpc \u8bbe\u7f6e\u5f71\u54cd\u8be5\u51fd\u6570\u7684\u8f93\u51fa\u3002\u5982\u679c\u5df2\u542f\u7528\uff0c\u90a3\u4e48\u5728 parse_str() \u89e3\u6790\u4e4b\u524d\uff0c\u53d8\u91cf\u4f1a\u88ab addslashes() \u8f6c\u6362\u3002<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>parse_str(\"a=this&amp;b=is&amp;c=flag\");<br>echo $a.\" \";<br>echo $b.\" \";<br>echo $c;<br>?&gt;<br>\/\/this is flag<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">parse_str<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">\u628av1\u7684\u503c\u76f8\u5e94\u7684\u6362\u6210\u952e\u503c\u5bf9\u518d\u5b58\u5165v2<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>\/\/ \u6a21\u62df\u4f20\u5165\u7684 URL \u67e5\u8be2\u5b57\u7b26\u4e32<br>$query = \"username=alice&amp;role=admin\";<br>\u200b<br>\/\/ \u7b2c\u4e8c\u4e2a\u53c2\u6570\u6307\u5b9a\u5b58\u653e\u89e3\u6790\u7ed3\u679c\u7684\u6570\u7ec4<br>parse_str($query, $params);<br>\u200b<br>echo \"\u7528\u6237\u540d\uff1a\" . $params['username'] . \"\\n\";  \/\/ \u8f93\u51fa\uff1a\u7528\u6237\u540d\uff1aalice<br>echo \"\u89d2\u8272\uff1a\" . $params['role'] . \"\\n\"; &nbsp; &nbsp; &nbsp;  \/\/ \u8f93\u51fa\uff1a\u89d2\u8272\uff1aadmin<br>?&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">strrev<\/h2>\n\n\n\n<p>\u53cd\u8f6c\u5b57\u7b26\u4e32<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>echo strrev(\"hello\");<br>?&gt;<br>\/\/olleh<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5f02\u5e38\u5904\u7406<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">\u5e38\u89c1\u7684 PHP \u5f02\u5e38\u7c7b<br>Exception<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aException \u662f\u6240\u6709\u5f02\u5e38\u7c7b\u7684\u57fa\u7c7b\u3002\u4efb\u4f55\u672a\u88ab\u7279\u5b9a\u5f02\u5e38\u7c7b\u6355\u83b7\u7684\u5f02\u5e38\u90fd\u4f1a\u4f5c\u4e3a Exception \u7c7b\u578b\u5904\u7406\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u629b\u51fa\u4e00\u4e2a\u672a\u6307\u5b9a\u7c7b\u578b\u7684\u5f02\u5e38\u65f6\uff0c\u9ed8\u8ba4\u4f1a\u521b\u5efa\u4e00\u4e2a Exception \u5bf9\u8c61\u3002\u8fd9\u4e2a\u5bf9\u8c61\u5305\u542b\u9519\u8bef\u6d88\u606f\u3001\u9519\u8bef\u7801\u3001\u6587\u4ef6\u540d\u548c\u884c\u53f7\u7b49\u4fe1\u606f\u3002<br>RuntimeException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aRuntimeException \u7528\u4e8e\u8868\u793a\u8fd0\u884c\u65f6\u53d1\u751f\u7684\u975e\u9884\u671f\u9519\u8bef\u3002\u8fd9\u4e9b\u9519\u8bef\u901a\u5e38\u662f\u5728\u6b63\u5e38\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\u53d1\u751f\u7684\uff0c\u800c\u4e0d\u662f\u7531\u4e8e\u7f16\u7a0b\u9519\u8bef\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u67d0\u4e2a\u51fd\u6570\u6216\u65b9\u6cd5\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\u9047\u5230\u4e0d\u53ef\u9884\u89c1\u7684\u95ee\u9898\uff08\u5982\u8d44\u6e90\u4e0d\u8db3\uff09\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa RuntimeException\u3002<br>LogicException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aLogicException \u7528\u4e8e\u8868\u793a\u903b\u8f91\u4e0a\u7684\u9519\u8bef\uff0c\u901a\u5e38\u662f\u7531\u4e8e\u7f16\u7a0b\u9519\u8bef\u5bfc\u81f4\u7684\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u4ee3\u7801\u903b\u8f91\u51fa\u73b0\u95ee\u9898\uff0c\u4f8b\u5982\u53c2\u6570\u9a8c\u8bc1\u5931\u8d25\u6216\u8fdd\u53cd\u4e86\u67d0\u4e9b\u524d\u63d0\u6761\u4ef6\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa LogicException\u3002<br>InvalidArgumentException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aInvalidArgumentException \u7ee7\u627f\u81ea LogicException\uff0c\u7528\u4e8e\u8868\u793a\u4f20\u9012\u7ed9\u51fd\u6570\u6216\u65b9\u6cd5\u7684\u53c2\u6570\u65e0\u6548\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u51fd\u6570\u6216\u65b9\u6cd5\u63a5\u6536\u5230\u4e0d\u7b26\u5408\u9884\u671f\u7684\u53c2\u6570\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa InvalidArgumentException\u3002<br>OutOfRangeException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aOutOfRangeException \u4e5f\u7ee7\u627f\u81ea LogicException\uff0c\u7528\u4e8e\u8868\u793a\u8bbf\u95ee\u6570\u7ec4\u6216\u96c6\u5408\u65f6\u7d22\u5f15\u8d85\u51fa\u8303\u56f4\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u5c1d\u8bd5\u8bbf\u95ee\u4e0d\u5b58\u5728\u7684\u6570\u7ec4\u5143\u7d20\u6216\u96c6\u5408\u6210\u5458\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa OutOfRangeException\u3002<br>OutOfBoundsException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aOutOfBoundsException \u4e0e OutOfRangeException \u7c7b\u4f3c\uff0c\u4f46\u66f4\u901a\u7528\uff0c\u9002\u7528\u4e8e\u4efb\u4f55\u8d85\u51fa\u8fb9\u754c\u7684\u8bbf\u95ee\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u5c1d\u8bd5\u8bbf\u95ee\u8d85\u51fa\u5408\u6cd5\u8303\u56f4\u7684\u6570\u636e\u7ed3\u6784\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa OutOfBoundsException\u3002<br>DomainException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aDomainException \u7528\u4e8e\u8868\u793a\u503c\u4e0d\u5728\u6709\u6548\u8303\u56f4\u5185\u7684\u60c5\u51b5\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u67d0\u4e2a\u503c\u4e0d\u7b26\u5408\u4e1a\u52a1\u89c4\u5219\u6216\u6570\u636e\u6a21\u578b\u7684\u8981\u6c42\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa DomainException\u3002<br>LengthException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aLengthException \u7528\u4e8e\u8868\u793a\u957f\u5ea6\u76f8\u5173\u7684\u95ee\u9898\uff0c\u4f8b\u5982\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\u957f\u5ea6\u4e0d\u6ee1\u8db3\u8981\u6c42\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u68c0\u6d4b\u5230\u957f\u5ea6\u4e0d\u7b26\u5408\u9884\u671f\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa LengthException\u3002<br>BadFunctionCallException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aBadFunctionCallException \u7528\u4e8e\u8868\u793a\u8c03\u7528\u4e86\u4e0d\u6b63\u786e\u7684\u51fd\u6570\u6216\u65b9\u6cd5\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u8c03\u7528\u4e86\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u51fd\u6570\u6216\u65b9\u6cd5\uff0c\u6216\u8005\u4ee5\u9519\u8bef\u7684\u65b9\u5f0f\u8c03\u7528\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa BadFunctionCallException\u3002<br>BadMethodCallException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aBadMethodCallException \u7528\u4e8e\u8868\u793a\u8c03\u7528\u4e86\u4e0d\u6b63\u786e\u7684\u65b9\u6cd5\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u8c03\u7528\u4e86\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u65b9\u6cd5\uff0c\u6216\u8005\u4ee5\u9519\u8bef\u7684\u65b9\u5f0f\u8c03\u7528\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa BadMethodCallException\u3002<br>UnexpectedValueException<br>\u200b<br>\u4f7f\u7528\u573a\u666f\uff1aUnexpectedValueException \u7528\u4e8e\u8868\u793a\u6536\u5230\u4e86\u4e00\u4e2a\u610f\u5916\u7684\u503c\u3002<br>\u5e95\u5c42\u539f\u7406\uff1a\u5f53\u63a5\u6536\u5230\u7684\u503c\u4e0d\u7b26\u5408\u9884\u671f\u683c\u5f0f\u6216\u7c7b\u578b\u65f6\uff0c\u53ef\u4ee5\u629b\u51fa UnexpectedValueException\u3002<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">toString<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">\u5c06\u4e00\u4e2a\u5bf9\u8c61\u4f5c\u4e3a\u5b57\u7b26\u4e32\u4f7f\u7528\u65f6\uff08echo &lt; \u4e00\u4e2a\u5bf9\u8c61&gt;\uff09\uff0cphp \u4f1a\u81ea\u52a8\u8c03\u7528\u8be5\u5bf9\u8c61\u7684 toString () \u65b9\u6cd5\u6765\u83b7\u53d6\u5b57\u7b26\u4e32\u8868\u793a\u3002\u6ce8\u610f\uff0c__toString () \u65b9\u6cd5\u5728\u5bf9\u8c61\u88ab\u9690\u5f0f\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u65f6\uff08echo &lt; \u4e00\u4e2a\u5bf9\u8c61 &gt;\uff09\u624d\u4f1a\u89e6\u53d1\uff0c\u5982\u679c\u76f4\u63a5\u8c03\u7528\u8be5\u65b9\u6cd5\uff0c\u4e0d\u4f1a\u6709\u4efb\u4f55\u6548\u679c php \u4e2d\uff0c\u81ea\u5e26 __toString() \u65b9\u6cd5\u7684\u5185\u7f6e\u7c7b\u6709\uff1aDataTime\u3001Exception\u3001SimpleXMLElement<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">filesystemiterator<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>$dir = new FilesystemIterator(__DIR__);<br>\u200b<br>foreach ($dir as $file) {<br> &nbsp;  echo $file-&gt;getFilename() . \"\\n\";<br>}<br>?&gt;<br>\/\/\u904d\u5386\u6587\u4ef6\u7c7b(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">DirectoryIterato<\/h2>\n\n\n\n<p>\u4e0e\u4e0a\u9762\u7684\u7c7b\u4f3c<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">getcwd()<\/h2>\n\n\n\n<p>\u8fd4\u56de\u5f53\u524d\u7684\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>echo \"\u5f53\u524d\u76ee\u5f55\u662f: \" . getcwd();<br>?&gt;\/\/\u5f53\u524d\u76ee\u5f55\u662f: D:\\php\u4ee3\u7801<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">is_file<\/h2>\n\n\n\n<p>\u68c0\u67e5\u662f\u4e0d\u662f\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>$path = \"flag.txt\";<br>\u200b<br>if (is_file($path)) {<br> &nbsp;  echo \"$path \u662f\u4e00\u4e2a\u6587\u4ef6\";<br>} else {<br> &nbsp;  echo \"$path \u4e0d\u662f\u6587\u4ef6\u6216\u4e0d\u5b58\u5728\";<br>}<br>?&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">trim<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">\u51fd\u6570\u79fb\u9664\u5b57\u7b26\u4e32\u4e24\u4fa7\u7684\u7a7a\u767d\u5b57\u7b26\u6216\u5176\u4ed6\u9884\u5b9a\u4e49\u5b57\u7b26\u3002\u4e00\u822c\u662f\u7528\u6765\u53bb\u9664\u5b57\u7b26\u4e32\u9996\u5c3e\u5904\u7684\u7a7a\u767d\u5b57\u7b26\uff08\u6216\u8005\u5176\u4ed6\u5b57\u7b26\uff09\uff0c\u4e00\u822c\u5728\u7528\u5728\u670d\u52a1\u7aef\u5bf9\u63a5\u6536\u7684\u7528\u6237\u6570\u636e\u8fdb\u884c\u5904\u7406\uff0c\u4ee5\u514d\u628a\u7528\u6237\u8bef\u8f93\u5165\u7684\u7a7a\u683c\u5b58\u50a8\u5230\u6570\u636e\u5e93\uff0c\u4e0b\u6b21\u5bf9\u6bd4\u6570\u636e\u65f6\u5019\u51fa\u9519<br>\u5173\u952e\u5c31\u5728\u4e8e\u5982\u4f55\u7ed5\u8fc7\u8fd9\u4e2a trim ()<br>trim \u51fd\u6570\u4f1a\u8fc7\u6ee4\u7a7a\u683c\u4ee5\u53ca \\n\\r\\t\\v\\0\uff0c\u4f46\u4e0d\u4f1a\u8fc7\u6ee4 \\f<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>(\u57fa\u672c\u4e0a\u662f\u6839\u636eshow\u4e0a\u9762\u6574\u7406\u7684\uff0c\u8fd8\u6709\u4e00\u8d77\u5176\u4ed6\u4e0a\u9762\u7684) intval &lt;?phpecho boolval [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,2],"tags":[],"class_list":["post-151","post","type-post","status-publish","format-standard","hentry","category-ctf","category-web"],"_links":{"self":[{"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/posts\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/101.201.119.158\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=151"}],"version-history":[{"count":2,"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":153,"href":"http:\/\/101.201.119.158\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions\/153"}],"wp:attachment":[{"href":"http:\/\/101.201.119.158\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/101.201.119.158\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/101.201.119.158\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}