duanmeng1858 2018-07-27 12:30
浏览 127

PHP json_decode在本地服务器上运行不正常,但在Web服务器上运行良好

I've a JSON file that I'm trying to decode in PHP. This seems to work just fine when I do it on my web-server, but when trying on my local server, using the same exact file, I get NULL back. Other files are decoded just fine across both servers, so I'm really clueless why this specific file is not.

The JSON file could be found here: http://boghdady.com/samsung_Page_1_Results.json

My webserver is on PHP v5.6 while the local one is on 7.2. I've verified that the file syntax is fine, using https://www.freeformatter.com/json-validator.html

Echoing json_last_error on my local server outputs 10. I've tried all sorts of functions to convert the string to UTF-8 ahead of doing the json_decode, but results remain NULL. This is even though the file is originally in UTF-8 anyways.

Could anybody please help with this? As it is really driving me nuts.

Update 1, regarding the proposed solution from the other similar question: I've tried applying the fix indicated in json_decode produces error "Single unpaired UTF-16 surrogate in unicode escape" and returns null However, the eval() there lead to even more problems. Some of the text within the JSON string was considered as a variable by PHP, and thus it failed. Some examples of the errors received:

<b>Notice</b>:  Undefined variable: GSI_TCPIP_IP_ADDR in <b>C:\Users\boghdady\Desktop\Server\Shodan\include\functions.php(73) : eval()'d code</b> on line <b>1</b><br />
<br />
<b>Notice</b>:  Undefined variable: O in <b>C:\Users\boghdady\Desktop\Server\Shodan\include\functions.php(73) : eval()'d code</b> on line <b>1</b><br />
<br />

Is it possible to explain to me the issue within the JSON file in more details? I could write a function to fix it if I understand what it is.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥20 求一个html代码,有偿