PHP5.1下启用json_encode方法
php5.2之后才将php-json作为标准扩展,一些Linux发行版上的php版本依然还是5.1.x,如SuSE10.1 , 导致使用json很不方便。网上也有一些文章介绍如何在SuSE10SP1下启用该扩展,如:
Enabling JSON on PHP 5.1.2 in SLES10
可惜这篇文章的方法现在已经不能用了。这里介绍一些解决方法
方法一:直接用php写json_encode和json_decode的函数,然后调用,这个网上已经有一些开源的代码了,如 Service JSON 方法比较简单,但是使用也不是那么得心应手。这里不再赘述。
方法二:安装扩展,需要先安装php5-devel,因为要使用phpize,脚本如下:
wget http://pecl.php.net/get/json -O json-1.2.1.tgz tar -xf json-1.2.1.tgz cd json-1.2.1 phpize ./configure make make install echo "extension=json.so" >> /etc/php5/apache2/php.ini # 这一句根据自己的环境执行 |
在make install后会提示扩展路径,根据自己的情况配置即可。
原创文章如转载,请注明:转载自CODIGG [ http://www.codigg.com/ ]
本文链接地址:http://www.codigg.com/2009/09/suse-php-5-1-2-json-encode-decode/


九月 3rd, 2009 at 10:24
SUSE10SP1安装盘里面没有这个东东…
[回复]
六月 3rd, 2011 at 15:41
2746491 beers on the wall.
[回复]
一月 25th, 2012 at 06:52
˙ţC
[回复]
一月 31st, 2012 at 12:42
The moment I first left a comment I clicked your – Notify me when new comments are added- – right now every moment a comment is added in I end up with three e-mail along with typically the exact same comment. There has to be any means you can erase me from that system? Thanks!
[回复]
二月 1st, 2012 at 22:40
The moment I originally commented I clicked your -’Notify me when new comments are added’- – right now each time a new comment is added in I end up with two messages together with typically the precise same comment. Is there possibly any way you can remove me out of that system? Thanks!
[回复]
二月 3rd, 2012 at 08:22
Very well written story. It will be supportive to everyone who usess it, including yours truly
. Keep doing what you are doing – i will definitely read more posts.
[回复]
二月 3rd, 2012 at 12:30
A remarkable talk may be worth a comment. I believe you need to create much more on this matter, may possibly not be a “taboo” area of interest but yet usually consumers are not enough to communicate on this sort of subjects. Regards. ! . !
[回复]
二月 7th, 2012 at 06:01
… [Trackback]…
[...] Read More Infos here: codigg.com/2009/09/suse-php-5-1-2-json-encode-decode/ [...]…