What's the PHP equivalent of ASP.NET ashx handlers?

半腔热情 提交于 2020-01-17 01:39:24

问题


I need to return a JSON encoded response to a flash http get request.

In ASP.NET, I do this with a ASHX handler. What's the PHP equivalent ? I mean in order that I only get JSON back, and not the <html> etc.


回答1:


You should put this on top of your script:

header('Content-Type: application/json; charset=utf-8');



回答2:


  • header('Content-type: application/json');
  • http://php.net/manual/en/function.json-encode.php


来源:https://stackoverflow.com/questions/2888153/whats-the-php-equivalent-of-asp-net-ashx-handlers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!