小编STE*_*EIN的帖子

将 JSON 输出保存到 json 文件

得到这个代码:

<?php
  $jsonurl = "https://newsapi.org/v1/articles?source=cnn&sortBy=top&apiKey=d8dfc55aa005430c9567416cac34e3fa";
  $json = file_get_contents($jsonurl);
  var_dump(json_decode($json));

          $file = fopen('news.json','w');
          fwrite($file, $json);
          fclose($file);
Run Code Online (Sandbox Code Playgroud)

但没有任何内容被保存到新news.json文件中,这是为什么呢?正如我所学到的 - 创建文件是使用这种方法完成的。(wfopen

php json

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

json ×1

php ×1