{"id":382,"date":"2016-04-20T14:33:13","date_gmt":"2016-04-20T06:33:13","guid":{"rendered":"http:\/\/www.sunlan021.com\/jc\/?p=382"},"modified":"2016-04-21T22:08:58","modified_gmt":"2016-04-21T14:08:58","slug":"%e5%a6%82%e4%bd%95%e6%89%b9%e9%87%8f%e6%b8%85%e7%90%86bom%e5%a4%b4%e4%bb%a3%e7%a0%81%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/www.sunlan021.com\/jc\/weberror\/382.html","title":{"rendered":"\u5982\u4f55\u6279\u91cf\u6e05\u7406BOM\u5934\u4ee3\u7801\u6587\u4ef6"},"content":{"rendered":"<p>\u6709\u4e9b\u7a0b\u5e8f\u5728windows\u4e3b\u673a\u4e0a\u8fd0\u884c\u6b63\u5e38\uff0c\u4f46\u5728linux\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u53ef\u80fd\u4f1a\u51fa\u73b0\u9519\u8bef\uff0c\u6700\u5e38\u89c1\u7684\u9519\u8bef\u662f\u767b\u5f55\u7f51\u7ad9\u540e\u53f0\u65f6\u9a8c\u8bc1\u7801\u4e0d\u663e\u793a\uff0c\u8fd9\u662f\u56e0\u4e3a\u7a0b\u5e8f\u4ee3\u7801\u4e2d\u81ea\u52a8\u751f\u6210\u4e86BOM\u5934<span style=\"font-family: Verdana;\">\uff080xEF 0xBB 0xBF\uff0c\u5373BOM\uff09<\/span>\u3002<span style=\"font-family: Verdana;\">\u5b83\u662f\u4e00\u4e32\u9690\u85cf\u7684\u5b57\u7b26\uff0c\u7528\u4e8e\u8ba9\u8bb0\u4e8b\u672c\u7b49\u7f16\u8f91\u5668\u8bc6\u522b\u8fd9\u4e2a\u6587\u4ef6\u662f\u5426\u4ee5UTF-8\u7f16\u7801\u3002\u5bf9\u4e8e\u4e00\u822c\u7684\u6587\u4ef6\uff0c\u8fd9\u6837\u5e76\u4e0d\u4f1a\u4ea7\u751f\u4ec0\u4e48\u9ebb\u70e6\u3002\u4f46\u5bf9\u4e8e\u8fd0\u884c\u5728linux\u4e3b\u673a\u4e0a\u7684php\u6587\u4ef6\u6765\u8bf4\uff0cBOM\u662f\u4e2a\u5927\u9ebb\u70e6\u3002<\/span><\/p>\n<p>\u6211\u4eec\u4e0d\u6e05\u695a\u90a3\u4e2a\u6587\u4ef6\u4e2d\u5e26\u6709BOM\uff0c\u53ef\u7528\u4e00\u4e2a\u5c0f\u5c0f\u7684\u5de5\u5177\uff0c\u6279\u91cf\u6e05\u7406\u6240\u6709\u7f51\u7ad9\u6587\u4ef6\u4e2d\u7684BOM\uff0c\u975e\u5e38\u5b9e\u7528\uff0c\u5c06\u4e00\u4e2aphp\u6587\u4ef6\u4e0a\u4f20\u5230\u7a7a\u95f4\u6839\u76ee\u5f55\u4e2d\uff0c\u901a\u8fc7\u57df\u540d\u8fd0\u884c\u8be5\u6587\u4ef6\u5373\u53ef\u3002<\/p>\n<p>php\u6587\u4ef6\u767e\u5ea6\u7f51\u76d8\u4e0b\u8f7d\u5730\u5740\uff1a<span style=\"font-family: Verdana;\"><a href=\"http:\/\/pan.baidu.com\/s\/1jGyHFZC\" target=\"_blank\">http:\/\/pan.baidu.com\/s\/1jGyHFZC<\/a>\u00a0\uff08\u65e0\u6bd2\uff0c\u653e\u5fc3\u4f7f\u7528\uff09<\/span><\/p>\n<p>\u4e0b\u8f7d\u540e\u5c06<span style=\"font-family: Verdana;\">clear.php\u4e0a\u4f20\u5230\u7a7a\u95f4\u6839\u76ee\u5f55\u4e2d\uff0c\u8fd0\u884c\u4f60\u7684\u7f51\u7ad9\uff1awww.\u57df\u540d.com\/<span style=\"font-family: Verdana;\">clear.php\u00a0 \u5373\u53ef\u6279\u91cf\u6e05\u7406\u6240\u6709\u6587\u4ef6\u4e2d\u7684BOM\u5934\u3002<\/span><\/span><\/p>\n<p>\u8be5clear.php\u91cc\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre lang=\"\u201dphp\u201d\" line=\"\u201d1\u2033\"><span style=\"font-family: Verdana;\">&lt;?php\r\nif (isset($_GET['dir'])){ \/\/\u8bbe\u7f6e\u6587\u4ef6\u76ee\u5f55\r\n$basedir=$_GET['dir'];\r\n}else{\r\n$basedir = '.';\r\n}\r\n$auto = 1;\r\ncheckdir($basedir);\r\nfunction checkdir($basedir){\r\nif ($dh = opendir($basedir)) {\r\nwhile (($file = readdir($dh)) !== false) {\r\nif ($file != '.' &amp;&amp; $file != '..'){\r\nif (!is_dir($basedir.\"\/\".$file)) {\r\necho \"filename: $basedir\/$file \".checkBOM(\"$basedir\/$file\").\" &lt;br&gt;\";\r\n}else{\r\n$dirname = $basedir.\"\/\".$file;\r\ncheckdir($dirname);\r\n}\r\n}\r\n}\r\nclosedir($dh);\r\n}\r\n}\r\nfunction checkBOM ($filename) {\r\nglobal $auto;\r\n$contents = file_get_contents($filename);\r\n$charset[1] = substr($contents, 0, 1);\r\n$charset[2] = substr($contents, 1, 1);\r\n$charset[3] = substr($contents, 2, 1);\r\nif (ord($charset[1]) == 239 &amp;&amp; ord($charset[2]) == 187 &amp;&amp; ord($charset[3]) == 191) {\r\nif ($auto == 1) {\r\n$rest = substr($contents, 3);\r\nrewrite ($filename, $rest);\r\nreturn (\"&lt;font color=red&gt;BOM found, automatically removed.&lt;\/font&gt;\");\r\n}else {\r\nreturn (\"&lt;font color=red&gt;BOM found.&lt;\/font&gt;\");\r\n}\r\n}else return (\"BOM Not Found.\");\r\n}\r\nfunction rewrite ($filename, $data) {\r\n$filenum = fopen($filename, \"w\");\r\nflock($filenum, LOCK_EX);\r\nfwrite($filenum, $data);\r\nfclose($filenum);\r\n}\r\n?&gt;<\/span>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e9b\u7a0b\u5e8f\u5728windows\u4e3b\u673a\u4e0a\u8fd0\u884c\u6b63\u5e38\uff0c\u4f46\u5728linux\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u53ef\u80fd\u4f1a\u51fa\u73b0\u9519\u8bef\uff0c\u6700\u5e38\u89c1\u7684\u9519\u8bef\u662f\u767b\u5f55\u7f51\u7ad9\u540e\u53f0\u65f6\u9a8c\u8bc1\u7801\u4e0d\u663e\u793a\uff0c\u8fd9\u662f\u56e0\u4e3a\u7a0b\u5e8f\u4ee3\u7801\u4e2d\u81ea\u52a8\u751f\u6210\u4e86BOM\u5934\uff080xEF 0xBB 0xBF\uff0c\u5373BOM\uff09\u3002\u5b83\u662f\u4e00\u4e32\u9690\u85cf\u7684\u5b57\u7b26\uff0c\u7528\u4e8e\u8ba9\u8bb0\u4e8b\u672c\u7b49\u7f16\u8f91\u5668\u8bc6\u522b\u8fd9\u4e2a\u6587\u4ef6\u662f\u5426\u4ee5UTF-8\u7f16\u7801\u3002\u5bf9\u4e8e\u4e00\u822c\u7684\u6587\u4ef6\uff0c\u8fd9\u6837\u5e76\u4e0d\u4f1a\u4ea7\u751f\u4ec0\u4e48\u9ebb\u70e6\u3002\u4f46\u5bf9\u4e8e\u8fd0\u884c\u5728linux\u4e3b\u673a\u4e0a\u7684php\u6587\u4ef6\u6765\u8bf4\uff0cBOM\u662f\u4e2a\u5927\u9ebb\u70e6\u3002 \u6211\u4eec\u4e0d\u6e05\u695a\u90a3\u4e2a\u6587\u4ef6\u4e2d\u5e26\u6709BOM\uff0c\u53ef\u7528\u4e00\u4e2a\u5c0f\u5c0f\u7684\u5de5\u5177\uff0c\u6279\u91cf\u6e05\u7406\u6240\u6709\u7f51\u7ad9\u6587\u4ef6\u4e2d\u7684BOM\uff0c\u975e\u5e38\u5b9e\u7528\uff0c\u5c06\u4e00\u4e2aphp\u6587\u4ef6\u4e0a\u4f20\u5230\u7a7a\u95f4\u6839\u76ee\u5f55\u4e2d\uff0c\u901a\u8fc7\u57df\u540d\u8fd0\u884c\u8be5\u6587\u4ef6\u5373\u53ef\u3002 php\u6587\u4ef6\u767e\u5ea6\u7f51\u76d8\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/pan.baidu&#8230; <a href=\"https:\/\/www.sunlan021.com\/jc\/weberror\/382.html\" class=\"readmore\">\u9605\u8bfb\u5168\u6587<span class=\"screen-reader-text\">\u5982\u4f55\u6279\u91cf\u6e05\u7406BOM\u5934\u4ee3\u7801\u6587\u4ef6<\/span><span class=\"fa fa-angle-double-right\" aria-hidden=\"true\"><\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/posts\/382"}],"collection":[{"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/comments?post=382"}],"version-history":[{"count":1,"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/posts\/382\/revisions"}],"predecessor-version":[{"id":383,"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/posts\/382\/revisions\/383"}],"wp:attachment":[{"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/media?parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/categories?post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sunlan021.com\/jc\/wp-json\/wp\/v2\/tags?post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}