Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

PHP json_encode返回false的问题

echo json_encode(["success"=>true,"message"=>"订单完成"],JSON_UNESCAPED_UNICODE);
返回false,
但是我其他的php页面一样的格式就是返回json后的字符串?
这个是什么问题呢?
图片.png
图片.png
图片.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
//方案1 :使用  JSON_THROW_ON_ERROR options 参数来将错误直接输出
json_encode(["success"=>true,"message"=>"订单完成"],JSON_UNESCAPED_UNICODE|`JSON_THROW_ON_ERROR`);

// 方案2 :使用 json_last_error_msg() 打印 json 处理过程中的错误信息、代码。
var_dump(json_last_error_msg());
var_dump(json_last_error());


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...