Zend_Json的使用
来源:互联网 发布:lol服务器ip 端口 编辑:程序博客网 时间:2024/06/04 17:50
Zend本身提供了许多有用的工具来方便使用。比如这次提到的Zend_Json。本身就非常便利。该类处于这个目录下:
Zend/
Json/
Decoder.php
Encoder.php
Exception.php
Json.php
Encoding PHP Data Structure
With Zend_Json, encoding PHP data structure into JSON formatted string is really easy. All you have to do is include Zend_Json
to your PHP script and call Zend_Json::encode()
with the variable you want to encode as parameter:
require_once 'Zend/Json.php';$result = array('wine'=>3, 'sugar'=>4, 'lemon'=>22);echo Zend_Json::encode($result);
Reverse Operation: Decoding
Besides encoding, Zend_Json can also decode JSON formatted string. Provided a JSON formatted string, Zend_Json:decode()
will transform it into native PHP array:
require_once 'Zend/Json.php';$result = Zend_Json::decode( '{"wine":3,"sugar":4,"lemon":22}');print_r( $result);
Troubleshooting
Q: Why am I receiving the following error?
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in [PROJECT_PATH]/Zend/Json/Encoder.php on line 402
A: Your PHP version is too low. Make sure you are using PHP 5.1.4 or later.
- Zend_Json的使用
- 9.1 Zend_Json
- Zend_Json 简单介绍 --(手册)
- GUID使用的使用
- ${}的使用
- 的使用
- @[],@()的使用
- ->的使用
- +、-、*、/、%的使用
- &&的使用
- %:的使用
- Makefile中使用$$的使用
- Makefile中使用$$的使用
- Red5的使用--使用日志
- prefernce的使用具体使用
- 【工具使用】git 的使用
- 关于使用AsyncTaskLoader的使用
- 使用CABasicAnimation的基本使用
- 各种进程 守护进程 孤儿进程 僵尸进程
- CSS教程:彻底掌握Z-index属性
- 鼠标移到任务栏滚轮调节音量
- Open-source ARM simulators
- 算术编码(Arithmetic Coding)源代码
- Zend_Json的使用
- dba要做的事
- android google map 开发笔记
- Eddie Liu memorable New Year
- JS同源策略
- The question that you should ask yourself everyday
- Oracle的UTL_FILE.FOPEN的用法
- ofstream & ifstream
- 测试第一篇文章