dongzhang0418 2013-12-10 22:20
浏览 107
已采纳

如何通过php返回响应

I'm writing a php api with methods wired together by php routing, such that

dev.myphp.com/user/login?email=sdfsdf@fdfd.com&password=d514

will return a json/xml response.

However, I do not know how to return this response, even if I use json_encode or xml_encode to conver the data string.

Do I just need to uniquely echo the JSON string out?

  • 写回答

1条回答 默认 最新

  • dongmei9961 2013-12-10 22:35
    关注

    Always try to take data using POST method not GET , untill unless you don't find it less useful in caompare to POSt.

    use simply

    <?Php
    --- php code 
    
    return json_encode($resultdata);
    
    ?>
    

    it would be enough.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部