在file_get_content()函数中获取错误

时间:2017-11-30 10:05:54

标签: php json

我正在尝试使用PHP从以下JSON文件中获取数据。我的json数据是

  

{ “ERROR”:0, “STATUS”:2 “ORDERID”:15245611, “OPTRANSID”: “”, “PARTNERREQID”: “9876543299”, “MESSAGE”: “成功”, “USERVAR1”:” ”, “USERVAR2”: “”, “USERVAR3”: “”, “委员会”: “0.2000”}

我把代码编写为:

$data = "http://url.php"
$obj = json_decode(file_get_content($data),true);
echo $obj['STATUS'];

但是我没有得到它的输出。

请帮助我如何从网址获取状态。

我收到错误

  

致命错误:调用未定义的函数file_get_content()

你能帮我解决一下我在做错的事吗?谢谢

4 个答案:

答案 0 :(得分:1)

您的代码使用中存在拼写错误:

file_get_contents()代替file_get_content()

答案 1 :(得分:0)

你拼错了这个功能:试试这个

$data = "http://url.php"
$obj = json_decode(file_get_contents($data),true);
echo $obj['STATUS'];

答案 2 :(得分:0)

函数名称是worng 从

file_get_content

file_get_contents

答案 3 :(得分:0)

这是我从json获得价值的方式,希望这可以帮助你

$json = json_decode($response,true);
echo $json['STATUS'];