JSON未在php中编译


JSON not compiled in php

我在Ubuntu 12.04上安装了PHP 5.5.1-2版本,但JSON并没有与之捆绑在一起(据我所知)。

我已经读到,我将不得不使用--enablejson或--withjson选项重新安装php
所以我的问题是:

如何验证未安装JSON?

如果没有,我会像这样重新安装php吗:apt-get-install php-with json(我会包含--enable json吗)?

如果我重新安装php,我当前的设置会丢失吗?

感谢

如果您还没有安装:

sudo apt-get install php5-json

(更多信息:http://iteration99.com/2013/php-json-removed-from-php-5-5/)

不应覆盖任何其他设置。

JSON在ubuntu 上默认启用

#php -i | grep -i json
json
json support => enabled
json version => 1.2.1

测试是否存在json_encode(或任何其他JSON函数)。

调用它并观察错误,或者使用function_exists("json_encode")

Ubuntu 12.04不支持

sudo apt-get install php5-json

直接。安装程序会自动将其更改为

sudo apt-get install php5-common

我的建议应该是使用sudo apt-get install php5-common而不是sudo apt-get install php5-json,因为sudo apt-get install php5-common还会自动为您安装所有其他依赖项