PHP:JSON:将数据存储到json文件时出错

时间:2015-12-28 06:21:23

标签: php json

服务器上的原始JSON文件:

{
"4567": 6768
}

添加新数据的代码是,

$path = 'http://*****/variables.json';
$myVarsJson = file_get_contents($path);
$myVarsArr = json_decode($myVarsJson,true);

$myVarsArr['4587'] = 6767;  /want to add this key value pair to json and store it back on server

$myVarsJson = json_encode($myVarsArr);
file_put_contents($path, $myVarsJson);

保存内容文件后应该有,

{
"4567": 6768,
"4587": 6767

}

我得到的输出是

Warning: file_put_contents(): Only 0 of 31 bytes written, possibly out of free disk space

有什么想法吗?

0 个答案:

没有答案