doujiao1180 2014-10-09 12:37
浏览 31
已采纳

如何从php页面返回响应

I am trying to develop an interface between a desktop application using .asp and SQL database and a web-based mobile app using PHP and MySQL. Each app needs to interrogate and/or update each of the respective databases. The plan is to create separate pages on each side each to provide a particular function. For example if the mobile app needed to retrieve a client name from the desktop, the mobile app would hit the page with the statement

$info = get_client_info.asp?clientno=1233

$info might be a string "John|Smith|555-654-0985" which could then be exploded.

An identical page to send the data to the desktop might be

info = get_client_info.php?clientno=1233

I am, of course, familiar with the 'return' statement in a function call but from just a PHP page would I simply use an 'echo' statement instead of the return, like I would with AJAX.

Also, assuming the above is correct, would I follow the echo with exit(); if it were within a conditional block and I wanted to terminate the page code early?

  • 写回答

1条回答 默认 最新

  • donglulong0877 2014-10-09 13:08
    关注

    You can indeed use echo to output a string to the browser.

    To make it more robust and nice for future uses consider outputting in json and parsing that on the platform.

    PHP has built in functions to both parse and encode json. This will make it easier for you to understand the clear text protocol in the future. Note that this is not canonical truth, but personal opinion.

    If you want to stop execution of the script use http://php.net/manual/en/function.exit.php .

    Good luck with your solutions.

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

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作