Home >Backend Development >PHP Tutorial >PHP接口 给C#程序调用 返回值以json格式 怎么实现?是return还是echo

PHP接口 给C#程序调用 返回值以json格式 怎么实现?是return还是echo

WBOY
WBOYOriginal
2016-06-20 12:46:191129browse

求解!!!PHP接口 给C#程序调用 返回值以json格式 怎么实现?是return还是echo,到底是用return返回吗?
echo 有用吗?


回复讨论(解决方案)

当然是 echo 啦

return只能在php内部使用
对外,你要给别人解析,你就理解成输出,用echo

exit(需要输出的内容)

当然是echo了,如果是json最好加上header标识

<?php$ret = array(    'name' => 'fdipzone');header('content-type:application/json;charset=utf8');echo json_encode($ret);?>

echo 或者print_r都行

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
Previous article:PHP报错配置Next article:关于两页面编码不一样