首页 > 这样写为什么不能更新内容

这样写为什么不能更新内容

<?php
$jsonOr=file_get_contents("json.json");
$jsonDe=json_decode($jsonOr);
array_push($jsonDe,array($_POST["title"],$_POST["content"]));
$jsonEn=json_encode($jsonDe);
file_put_contents($jsonOr,$jsonEn;);
?>

file_put_contents($jsonOr,$jsonEn;); ????
先搞清楚这个函数每个参数的意义,检查一下文件写入权限,再把语法错误修改一下好伐~


$jsonDe=json_decode($jsonOr);
建议加第二个参数,默认的话,decode出来的东西是对象,而不是数组。

【热门文章】
【热门文章】