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.

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?