{"id":47439,"date":"2024-12-02T08:20:36","date_gmt":"2024-12-02T00:20:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47439\/"},"modified":"2024-12-02T08:20:36","modified_gmt":"2024-12-02T00:20:36","slug":"php%e5%87%bd%e6%95%b0%e7%89%88%e6%9c%ac%e6%9b%b4%e6%96%b0%e5%af%b9%e6%80%a7%e8%83%bd%e5%92%8c%e5%ae%89%e5%85%a8%e6%80%a7%e6%9c%89%e5%93%aa%e4%ba%9b%e5%bd%b1%e5%93%8d%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47439\/","title":{"rendered":"php\u51fd\u6570\u7248\u672c\u66f4\u65b0\u5bf9\u6027\u80fd\u548c\u5b89\u5168\u6027\u6709\u54ea\u4e9b\u5f71\u54cd\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>php\u51fd\u6570\u7248\u672c\u66f4\u65b0\u5bf9\u6027\u80fd\u548c\u5b89\u5168\u6027\u6709\u54ea\u4e9b\u5f71\u54cd\uff1f<\/h1>\n<p>\u5c0f\u4f19\u4f34\u4eec\u6709\u6ca1\u6709\u89c9\u5f97\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u5f88\u6709\u610f\u601d\uff1f\u6709\u610f\u601d\u5c31\u5bf9\u4e86\uff01\u4eca\u5929\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aphp\u51fd\u6570\u7248\u672c\u66f4\u65b0\u5bf9\u6027\u80fd\u548c\u5b89\u5168\u6027\u6709\u54ea\u4e9b\u5f71\u54cd\uff1f\u300b<\/span>\uff0c\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u5728\u5b66\u4e60\u4e2d\u5bf9\u5176\u4e2d\u90e8\u5206\u77e5\u8bc6\u70b9\u6709\u7591\u95ee\uff0c\u6216\u8bb8\u770b\u4e86\u672c\u6587\u5c31\u80fd\u5e2e\u5230\u4f60\uff01<\/p>\n<p>PHP \u51fd\u6570\u7248\u672c\u66f4\u65b0\u7684\u5f71\u54cd\uff1a\u6027\u80fd\u5f71\u54cd\uff1a\u66f4\u65b0\u7248\u672c\u901a\u5e38\u4f18\u5316\u4ee3\u7801\uff0c\u63d0\u9ad8\u6027\u80fd\uff0c\u4f8b\u5982\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u6216\u52a0\u5feb\u6267\u884c\u901f\u5ea6\u3002\u5b89\u5168\u6027\u5f71\u54cd\uff1a\u65b0\u7248\u672c\u4fee\u590d\u5b89\u5168\u6f0f\u6d1e\uff08\u5982\u7f13\u51b2\u533a\u6ea2\u51fa\u6216 XSS\uff09\uff0c\u589e\u5f3a\u5e94\u7528\u7a0b\u5e8f\u5b89\u5168\u6027\uff0c\u9632\u6b62\u6076\u610f\u653b\u51fb\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729918170671c74da29097.jpg\" class=\"aligncenter\" title=\"php\u51fd\u6570\u7248\u672c\u66f4\u65b0\u5bf9\u6027\u80fd\u548c\u5b89\u5168\u6027\u6709\u54ea\u4e9b\u5f71\u54cd\uff1f\u63d2\u56fe\" alt=\"php\u51fd\u6570\u7248\u672c\u66f4\u65b0\u5bf9\u6027\u80fd\u548c\u5b89\u5168\u6027\u6709\u54ea\u4e9b\u5f71\u54cd\uff1f\u63d2\u56fe\" \/><\/p>\n<h2>PHP \u51fd\u6570\u7248\u672c\u66f4\u65b0\u5bf9\u6027\u80fd\u548c\u5b89\u5168\u6027\u6709\u54ea\u4e9b\u5f71\u54cd\uff1f<\/h2>\n<p><strong>\u7b80\u4ecb<\/strong><\/p>\n<p>PHP \u51fd\u6570\u7684\u7248\u672c\u66f4\u65b0\u4e0d\u4ec5\u80fd\u5f15\u5165\u65b0\u529f\u80fd\uff0c\u8fd8\u80fd\u63d0\u9ad8\u6027\u80fd\u548c\u5b89\u5168\u6027\u3002\u4e86\u89e3\u66f4\u65b0\u5982\u4f55\u5f71\u54cd\u8fd9\u4e9b\u65b9\u9762\u81f3\u5173\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4f60\u505a\u51fa\u660e\u667a\u7684\u51b3\u5b9a\uff0c\u4f18\u5316\u4f60\u7684 PHP \u4ee3\u7801\u3002<\/p>\n<p><strong>\u6027\u80fd\u5f71\u54cd<\/strong><\/p>\n<p>\u66f4\u65b0\u540e\u7684\u7248\u672c\u901a\u5e38\u4f1a\u4f18\u5316\u5e95\u5c42\u4ee3\u7801\uff0c\u901a\u8fc7\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u6216\u63d0\u9ad8\u6267\u884c\u901f\u5ea6\u6765\u63d0\u9ad8\u6027\u80fd\u3002\u4f8b\u5982\uff0c\u4ece PHP 7.0 \u5347\u7ea7\u5230 PHP 7.1\uff0c<code>array_keys()<\/code> \u51fd\u6570\u7684\u5e73\u5747\u6267\u884c\u65f6\u95f4\u964d\u4f4e\u4e86\u7ea6 10%\u3002<\/p>\n<p><strong>\u5b89\u5168\u6027\u5f71\u54cd<\/strong><\/p>\n<p>\u65b0\u7248\u672c\u4f1a\u4fee\u590d\u5b89\u5168\u6f0f\u6d1e\uff0c\u4f8b\u5982\u7f13\u51b2\u533a\u6ea2\u51fa\u6216\u8de8\u7ad9\u70b9\u811a\u672c\uff08XSS\uff09\u3002\u8fd9\u4e9b\u4fee\u590d\u7a0b\u5e8f\u53ef\u4ee5\u589e\u5f3a\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u7684\u5b89\u5168\u6027\uff0c\u9632\u6b62\u6076\u610f\u653b\u51fb\u3002\u4f8b\u5982\uff0cPHP 5.3.0 \u4e2d\u5f15\u5165\u4e86\u9488\u5bf9 SQL \u6ce8\u5165\u7684mysqli_real_escape_string() \u51fd\u6570\uff0c\u5b83\u53ef\u4ee5\u6709\u6548\u9632\u6b62\u6b64\u7c7b\u653b\u51fb\u3002<\/p>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p>\u4e3a\u4e86\u5c55\u793a\u7248\u672c\u66f4\u65b0\u7684\u5f71\u54cd\uff0c\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684 PHP \u811a\u672c\u6765\u6d4b\u8bd5 <code>array_keys()<\/code> \u51fd\u6570\u7684\u6267\u884c\u65f6\u95f4\uff1a<\/p>\n<pre>$arr = range(1, 1000000);\n$start = microtime(true);\narray_keys($arr);\n$end = microtime(true);\necho \"PHP 7.0: \" . ($end - $start) . \" seconds\\n\";\n$start = microtime(true);\narray_keys($arr);\n$end = microtime(true);\necho \"PHP 7.1: \" . ($end - $start) . \" seconds\\n\";<\/pre>\n<p>\u8fd0\u884c\u6b64\u811a\u672c\u4f1a\u5728 PHP 7.0 \u548c 7.1 \u4e0a\u6253\u5370\u6267\u884c\u65f6\u95f4\u3002\u4f60\u4f1a\u6ce8\u610f\u5230\uff0cPHP 7.1 \u7684\u6267\u884c\u65f6\u95f4\u663e\u8457\u51cf\u5c11\uff0c\u8fd9\u8bc1\u660e\u4e86\u66f4\u65b0\u7248\u672c\u7684\u6027\u80fd\u63d0\u5347\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>php\u51fd\u6570\u7248\u672c\u66f4\u65b0\u5bf9\u6027\u80fd\u548c\u5b89\u5168\u6027\u6709\u54ea\u4e9b\u5f71\u54cd\uff1f \u5c0f\u4f19\u4f34\u4eec\u6709\u6ca1\u6709\u89c9\u5f97\u5b66\u4e60\u6587\u7ae0\u5f88\u6709\u610f\u601d\uff1f\u6709\u610f\u601d\u5c31\u5bf9\u4e86\uff01\u4eca\u5929\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765\u300aphp\u51fd\u6570\u7248\u672c\u66f4\u65b0\u5bf9\u6027\u80fd\u548c\u5b89\u5168\u6027\u6709\u54ea\u4e9b\u5f71\u54cd\uff1f\u300b\uff0c\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230\uff0c\u82e5\u662f\u5728\u5b66\u4e60\u4e2d\u5bf9\u5176\u4e2d\u90e8\u5206\u77e5\u8bc6\u70b9\u6709\u7591\u95ee\uff0c\u6216\u8bb8\u770b\u4e86\u672c\u6587\u5c31\u80fd\u5e2e\u5230\u4f60\uff01 PHP \u51fd\u6570\u7248\u672c\u66f4\u65b0\u7684\u5f71\u54cd\uff1a\u6027\u80fd\u5f71\u54cd\uff1a\u66f4\u65b0\u7248\u672c\u901a\u5e38\u4f18\u5316\u4ee3\u7801\uff0c\u63d0\u9ad8\u6027\u80fd\uff0c\u4f8b\u5982\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u6216\u52a0\u5feb\u6267\u884c\u901f\u5ea6\u3002\u5b89\u5168\u6027\u5f71\u54cd\uff1a\u65b0\u7248\u672c\u4fee\u590d\u5b89\u5168\u6f0f\u6d1e\uff08\u5982\u7f13\u51b2\u533a\u6ea2\u51fa\u6216 XSS\uff09\uff0c\u589e\u5f3a\u5e94\u7528\u7a0b\u5e8f\u5b89\u5168\u6027\uff0c\u9632\u6b62\u6076\u610f\u653b\u51fb\u3002 PHP \u51fd\u6570\u7248\u672c\u66f4\u65b0\u5bf9\u6027\u80fd\u548c\u5b89\u5168\u6027\u6709\u54ea\u4e9b\u5f71\u54cd\uff1f \u7b80\u4ecb PHP \u51fd\u6570\u7684\u7248\u672c\u66f4\u65b0\u4e0d\u4ec5\u80fd\u5f15\u5165\u65b0\u529f\u80fd\uff0c\u8fd8\u80fd\u63d0\u9ad8\u6027\u80fd\u548c\u5b89\u5168\u6027\u3002\u4e86\u89e3\u66f4\u65b0\u5982\u4f55\u5f71\u54cd\u8fd9\u4e9b\u65b9\u9762\u81f3\u5173\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4f60\u505a\u51fa\u660e\u667a\u7684\u51b3\u5b9a\uff0c\u4f18\u5316\u4f60\u7684 PHP \u4ee3\u7801\u3002 \u6027\u80fd\u5f71\u54cd \u66f4\u65b0\u540e\u7684\u7248\u672c\u901a\u5e38\u4f1a\u4f18\u5316\u5e95\u5c42\u4ee3\u7801\uff0c\u901a\u8fc7\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u6216\u63d0\u9ad8\u6267\u884c\u901f\u5ea6\u6765\u63d0\u9ad8\u6027\u80fd\u3002\u4f8b\u5982\uff0c\u4ece PHP 7.0 \u5347\u7ea7\u5230 PHP 7.1\uff0carray_keys() \u51fd\u6570\u7684\u5e73\u5747\u6267\u884c\u65f6\u95f4\u964d\u4f4e\u4e86\u7ea6 10%\u3002 \u5b89\u5168\u6027\u5f71\u54cd \u65b0\u7248\u672c\u4f1a\u4fee\u590d\u5b89\u5168\u6f0f\u6d1e\uff0c\u4f8b\u5982\u7f13\u51b2\u533a\u6ea2\u51fa\u6216\u8de8\u7ad9\u70b9\u811a\u672c\uff08XSS\uff09\u3002\u8fd9\u4e9b\u4fee\u590d\u7a0b\u5e8f\u53ef\u4ee5\u589e\u5f3a\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u7684\u5b89\u5168\u6027\uff0c\u9632\u6b62\u6076\u610f\u653b\u51fb\u3002\u4f8b\u5982\uff0cPHP 5.3.0 \u4e2d\u5f15\u5165\u4e86\u9488\u5bf9 SQL \u6ce8\u5165\u7684mysqli_real_escape_string() \u51fd\u6570\uff0c\u5b83\u53ef\u4ee5\u6709\u6548\u9632\u6b62\u6b64\u7c7b\u653b\u51fb\u3002 \u5b9e\u6218\u6848\u4f8b \u4e3a\u4e86\u5c55\u793a\u7248\u672c\u66f4\u65b0\u7684\u5f71\u54cd\uff0c\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684 PHP \u811a\u672c\u6765\u6d4b\u8bd5 array_keys() \u51fd\u6570\u7684\u6267\u884c\u65f6\u95f4\uff1a $arr = range(1, 1000000); $start = microtime(true); array_keys($arr); $end = microtime(true); echo &#8220;PHP 7.0: &#8221; . ($end &#8211; $start) . &#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-47439","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=47439"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47439\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}