php开发http json接口
2016-04-12 14:23
615 查看
php开发http json接口
PHP5.2开始内置了JSON的支持。当然,如果低于这个版本的话,那么市面上有很多PHP版本的实现,随便下一个用就OK啦。现在主要是说说PHP内置支持的JSON。很简单,两个函数:json_encode和json_decode。
<?php
$arr = array(
‘name’ => ‘林则徐’,
‘nick’ => ‘haran’
);
$json_string = json_encode($arr);
echo $json_string;
?>
注意,文件必须以utf-8的格式保存,否则encode的时候,没有输出。
<?php
$arr = array(
‘name’ => ‘林则徐’,
‘nick’ => ‘haran’,
‘contact’ => array(
’email’ => ‘url at qq dot com’,
‘website’ => ‘http://www.url.com’,
)
);
$json_string = json_encode($arr);
$obj = json_decode($json_string);
print_r($obj);
?>
http://www.kuaizh.com/?p=1132
相关文章推荐
- Android Volley 网络并发 监听网络队列完成
- 当你在浏览器地址栏输入一个URL后回车,将会发生的事情?
- Android: WebView加载网页的几种方式及网络异常处理
- http 请求头
- 使用域账号统一管理cisco网络设备
- DL:卷积神经网络(CNN)的一些学习网址
- angularJS里的$http.post传数据到php接收问题
- golang http服务器跨域问题解决
- 神经网络第一部分:背景Neural Networks, Part 1: Background
- 神经网络第二部分:神经元Neural Networks, Part 2: The Neuron
- 神经网络第三部分:网络Neural Networks, Part 3: The Network
- 神经网络第三部分:网络Neural Networks, Part 3: The Network
- 【ZOJ3933 The 16th Zhejiang University Programming ContestG】【费用流】Team Formation 最多组队条件下女
- PHP CURL HTTP研究
- 从贝叶斯方法谈到贝叶斯网络
- java.lang.ClassCastException: libcore.net.http.HttpURLConnectionImpl cannot be cast to javax.net.ssl
- 深度神经网络入门教程Deep Neural Networks: A Getting Started Tutorial
- 神经网络指南Hacker's guide to Neural Networks
- 学Http协议
- 用matlab训练数字分类的深度神经网络Training a Deep Neural Network for Digit Classification