1. 程式人生 > >json_decode時返回null

json_decode時返回null

某txt檔案,其中有json格式資料,通過file_get_contents連結之後json_decode之後為null,但是將其中json資料拷出之後json_decode正常,經過分析,是因為file_get_contents得到的資料前面有三個看不到的字元(無BOM 也是沒用的),所以只要將得到的字串,substr($str,3)就行了

經過驗證確實解決問題。