Home >php教程 >PHP源码 >php输出json格式数据

php输出json格式数据

PHP中文网
PHP中文网Original
2016-05-25 17:09:271137browse

php代码

<?php
 
header(‘Content-type:text/json’);     //这句是重点,它告诉接收数据的对象此页面输出的是json数据;
 
$json={“n”:”name”,”p”:”password”};           //虽然这行数据形式上是json格式,如果没有上面那句的话,它是不会被当做json格式的数据被处理的;
 
echo $json;
 
?>
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