【发布时间】:2019-11-17 00:13:49
【问题描述】:
大家好,我正在使用 php 从 txt 文件中读取一些数据
file_get_contents('../../Datafiles/allThreads.txt');
这将返回以下字符串
[{"OP":"ding","threadName":"","content":"","ID":6}]
当我尝试使用 lint 验证时,我没有任何问题,因此 json 是有效的。
但问题是,当我调用 json_decode 时,它一直返回 null:
$currentThreadasList = json_decode('../../Datafiles/allThreads.txt');
为什么会这样?我遵守所有规则?
【问题讨论】:
-
你必须在json_decode下指定内容,而不是路径
标签: php json jsondecoder