1 2 3 4 5 6 | <code><?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 ;);
?></code>
|
Copier après la connexion
Copier après la connexion
回复内容:
1 2 3 4 5 6 | <code><?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 ;);
?></code>
|
Copier après la connexion
Copier après la connexion
file_put_contents($jsonOr,$jsonEn;);
????
先搞清楚这个函数每个参数的意义,检查一下文件写入权限,再把语法错误修改一下好伐~
$jsonDe=json_decode($jsonOr);
建议加第二个参数,默认的话,decode出来的东西是对象,而不是数组。