在php中回显JSON数据 [英] Echoing JSON Data in php
本文介绍了在php中回显JSON数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试回显一些JSON数据.问题是数据包含变量,但是我的代码没有将变量放入字符串中. 这是我的代码:
Im trying to echo some JSON Data. The problem is the data contains variables but my code isn't putting the variables into the string. Heres my code:
$status = $row['Status'];
$priority = $row['Priority'];
echo '{"status":"$status","priority":"$priority"}' ;
此php回显
{"status":"$status","priority":"$priority"}
当我需要回声
{"status":"Completed","priority":"High"}
例如.我该如何解决?
推荐答案
只需使用 json_encode 函数
echo json_encode($row);
这篇关于在php中回显JSON数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文