{"id":395,"date":"2020-02-29T14:25:00","date_gmt":"2020-02-29T06:25:00","guid":{"rendered":"http:\/\/124.244.86.40:8080\/wordpress\/?p=395"},"modified":"2020-02-26T14:26:48","modified_gmt":"2020-02-26T06:26:48","slug":"php7-%e4%b8%8b%e6%aa%94%e6%a1%88%e5%90%8d%e7%a8%b1%e5%a4%aa%e9%95%b7%e5%b0%8e%e8%87%b4-glob-%e5%9b%9e%e5%82%b3-false-%e7%9a%84%e5%95%8f%e9%a1%8c","status":"publish","type":"post","link":"https:\/\/imuslab.com\/wordpress\/2020\/02\/29\/php7-%e4%b8%8b%e6%aa%94%e6%a1%88%e5%90%8d%e7%a8%b1%e5%a4%aa%e9%95%b7%e5%b0%8e%e8%87%b4-glob-%e5%9b%9e%e5%82%b3-false-%e7%9a%84%e5%95%8f%e9%a1%8c\/","title":{"rendered":"PHP7 \u4e0b\u6a94\u6848\u540d\u7a31\u592a\u9577\u5c0e\u81f4 glob \u56de\u50b3 false \u7684\u554f\u984c"},"content":{"rendered":"\n<p>\u5f88\u591a\u6642\u5019\u5728\u958b\u767c PHP \u7684\u6642\u5019\u6211\u5011\u90fd\u6703\u4f7f\u7528\u9019\u500b\u8d85\u7d1a\u65b9\u4fbf\u7684 glob(*) \u529f\u80fd\u3002\u7c21\u55ae\u4f86\u8aaa\u5c31\u662f\u628a\u4e00\u500b\u8cc7\u6599\u593e\u6216\u8def\u5f91\u5167\u7684\u6a94\u6848\u4ee5 array \u65b9\u5f0f\u56de\u50b3\u7684\u65b9\u6cd5\u3002\u7136\u800c\uff0c\u5728\u6700\u8fd1\u7684 ArOZ Online \u6e2c\u8a66\u4f3a\u670d\u5668\u66f4\u65b0\u4e4b\u5f8c\u767c\u73fe\u4e86 File Explorer \u5728\u958b\u555f\u67d0\u4e9b\u8cc7\u6599\u593e\u6642\u51fa\u73fe PHP ERROR \u7684\u554f\u984c\u3002\u5f8c\u4f86\u7d93\u904e\u4e00\u5806\u6aa2\u6e2c\u4e4b\u5f8c\u767c\u73fe\u539f\u4f86\u662f\u6a94\u6848\u540d\u7a31\u592a\u9577\u4e86\uff0c\u7d50\u679c glob \u5c31\u76f4\u63a5\u56de\u50b3 false \u3002<\/p>\n\n\n\n<p>\u539f\u672c\u7684 listdir.php<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Some code here for auth and var parsing\nif (file_exists($path) &amp;&amp; is_dir($path)){\n\t$filelist = glob($path . \"\/*\");\n\t\/\/Other code\n}<\/code><\/pre>\n\n\n\n<p>\u8981\u89e3\u6c7a\u9019\u500b\u554f\u984c\uff0c\u6211\u5011\u9700\u8981\u628a\u5b83\u6539\u6210\u4f7f\u7528 scandir \uff0c\u7136\u800c\u7531\u65bc scandir \u6703\u591a\u4e86\u5f88\u591a\u4ee3\u78bc\uff0c\u70ba\u4e86\u7bc0\u7701\u8655\u7406\u80fd\u529b\uff0c\u6211\u5011\u53ea\u5728\u9700\u8981\u7684\u6642\u5019\u4f7f\u7528 scandir \u5c31\u597d\u3002\u7d50\u679c\u65b0\u7684 glob \u90e8\u5206\u5c31\u8b8a\u6210\u4e86\u9019\u6a23\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Some code here for auth and var parsing\nif (file_exists($path) &amp;&amp; is_dir($path)){\n\t$filelist = glob($path . \"\/*\");\n\tif ($filelist === false){\n\t\t\/\/Something went wrong while trying to list the directory using glob. Try scandir\n\t\t$scanResults = scandir($path);\n\t\t$filelist = &#91;];\n\t\t$useAbnormalFilter = true;\n\t\tforeach ($scanResults as $fileObj){\n\t\t\tif ($fileObj != \".\" &amp;&amp; $fileObj != \"..\"){\n\t\t\t\tarray_push($filelist, $path . \"\/\" . $fileObj);\n\t\t\t}\n\t\t}\n\t}\n\t\/\/Other code\n}<\/code><\/pre>\n\n\n\n<p>\u5c31\u662f\u9019\u6a23\uff0cFile Explorer \u7684\u986f\u793a\u5c31\u56de\u5fa9\u6b63\u5e38\u4e86\u3002<br>\u5c0d\uff0c\u9019\u90fd\u662f Windows \u7684\u932f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u591a\u6642\u5019\u5728\u958b\u767c PHP \u7684\u6642\u5019\u6211\u5011\u90fd\u6703\u4f7f\u7528\u9019\u500b\u8d85\u7d1a\u65b9\u4fbf\u7684 glob(*) \u529f\u80fd\u3002\u7c21\u55ae\u4f86\u8aaa\u5c31\u662f\u628a\u4e00\u500b\u8cc7\u6599\u593e\u6216\u8def\u5f91\u5167\u7684\u6a94\u6848\u4ee5 array \u65b9\u5f0f\u56de\u50b3\u7684\u65b9\u6cd5\u3002\u7136\u800c\uff0c\u5728\u6700\u8fd1\u7684 ArOZ Online \u6e2c\u8a66\u4f3a\u670d\u5668\u66f4\u65b0\u4e4b\u5f8c\u767c\u73fe\u4e86 File Explorer \u5728\u958b\u555f\u67d0\u4e9b\u8cc7\u6599\u593e\u6642\u51fa\u73fe PHP ERROR \u7684\u554f\u984c\u3002\u5f8c\u4f86\u7d93\u904e\u4e00\u5806\u6aa2\u6e2c\u4e4b\u5f8c\u767c\u73fe\u539f\u4f86\u662f\u6a94\u6848\u540d\u7a31\u592a\u9577\u4e86\uff0c\u7d50\u679c glob \u5c31\u76f4\u63a5\u56de\u50b3 false \u3002 \u539f\u672c\u7684 listdir.php \u8981\u89e3\u6c7a\u9019\u500b\u554f\u984c\uff0c\u6211\u5011\u9700\u8981\u628a\u5b83\u6539\u6210\u4f7f\u7528 scandir \uff0c\u7136\u800c\u7531\u65bc scandir \u6703\u591a\u4e86\u5f88\u591a\u4ee3\u78bc\uff0c\u70ba\u4e86\u7bc0\u7701\u8655\u7406\u80fd\u529b\uff0c\u6211\u5011\u53ea\u5728\u9700\u8981\u7684\u6642\u5019\u4f7f\u7528 scandir \u5c31\u597d\u3002\u7d50\u679c\u65b0\u7684 glob \u90e8\u5206\u5c31\u8b8a\u6210\u4e86\u9019\u6a23\uff1a \u5c31\u662f\u9019\u6a23\uff0cFile Explorer \u7684\u986f\u793a\u5c31\u56de\u5fa9\u6b63\u5e38\u4e86\u3002\u5c0d\uff0c\u9019\u90fd\u662f Windows \u7684\u932f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[67,70,69,65,64,68],"class_list":["post-395","post","type-post","status-publish","format-standard","hentry","category-instructions-and-information","tag-bug","tag-error","tag-exception","tag-glob","tag-php7","tag-scandir"],"_links":{"self":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/comments?post=395"}],"version-history":[{"count":2,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts\/395\/revisions"}],"predecessor-version":[{"id":397,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/posts\/395\/revisions\/397"}],"wp:attachment":[{"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/media?parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/categories?post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imuslab.com\/wordpress\/wp-json\/wp\/v2\/tags?post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}