doumeng3345 2013-03-05 12:46
浏览 133

file_put_contents使用json_encode返回null

I am trying to place the json_encoded variable on to a file using file_put_contents. I do not know why its returning a null value on the destination file.

$json1=json_encode($php);
file_put_contents("path/text.txt",$json1);
  • 写回答

1条回答 默认 最新

  • douche3791 2013-03-05 12:53
    关注

    json_encode() will set a null value in elements that contain an invalid (non-UTF-8) character.

    Make sure your incoming data doesn't contain invalid characters. If it's coming from a different encoding, use iconv() to convert it to UTF-8 first.

    评论

报告相同问题?