json_decode時返回null

某txt文件,其中有json格式數據,經過file_get_contents連接以後json_decode以後爲null,可是將其中json數據拷出以後json_decode正常,通過分析,是由於file_get_contents獲得的數據前面有三個看不到的字符(無BOM 也是沒用的),因此只要將獲得的字符串,substr($str,3)就好了json 通過驗證確實解決問題。spa
相關文章
相關標籤/搜索