嘿,我正在尝试JSON
使用面向对象的 PHP构建宁静的 API。我的问题是JSON
在这种情况下您如何发送响应
这是我的代码
if($post->update()) {
echo
array('message' => 'Post updated')
} else {
echo
array('message' => 'Post not updated')
}
您需要将数组包装在 json_encode 中
if($post->update()) {
echo json_encode(
array('message' => 'Post updated')
);
} else {
echo json_decode(
array('message' => 'Post not updated')
);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句