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

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

WBOY
Release: 2016-06-20 12:46:19
Original
1147 people have browsed it

求解!!!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);?>
Copy after login

echo 或者print_r都行

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template