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

php输出json格式数据

PHP中文网
Release: 2016-05-25 17:09:27
Original
1142 people have browsed it

php代码

<?php
 
header(‘Content-type:text/json’);     //这句是重点,它告诉接收数据的对象此页面输出的是json数据;
 
$json={“n”:”name”,”p”:”password”};           //虽然这行数据形式上是json格式,如果没有上面那句的话,它是不会被当做json格式的数据被处理的;
 
echo $json;
 
?>
Copy after login
Related labels:
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template