Home  >  Article  >  Backend Development  >  菜鸟求教,如何返回JSONObject给客户端

菜鸟求教,如何返回JSONObject给客户端

WBOY
WBOYOriginal
2016-06-23 14:26:091216browse

本人在要实现android客户端登陆,然后服务端返回一个JSONObject给客户端的java程序,求教 如何返回JSONObject
比如sn=>123,fn=>234


回复讨论(解决方案)

json_encode

$rt_info = array("rand"=>$rd,"sessionId"=>session_id());
echo json_encode($rt_info);

这样写可以么,为什么客户端程序调试log显示会把整个PHP文字内容都作为返回值打印出来了,应该怎么返回

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn