Enable json_encode in PHP
As in http://www.php.net/manual/en/json.requirements.php
Requirements
There is no installation needed to use these functions; they are part of the PHP core.
Just PHP >= 5.2.0
Edit: saw in a comment also this
On RHEL5/CentOS5 add the EPEL repository (http://fedoraproject.org/wiki/EPEL).
After that, installation is as simple as:
sudo yum install php-pecl-json
Don't know if this apply for your question, I don't have a Centos server...
For Ubuntu:
sudo aptitude install php5-json
In my case, I came across this question because I was re-compiling PHP will ./configure --disable-all
and then individually adding in the extensions I needed. For the case of json_encode(), this is of course included in the JSON extension. To enable this extension, add the option --enable-json
to your configure command, i.e.:
./configure --disable-all --enable-json ...
(The "..." refers to the fact that you may have other extensions you may wish to enable.)
In general, any PHP extension can be enabled either by including the option --with-extname
or --enable-extname
(where "extname" is the name of the extension). You can figure out which one of these two syntaxes to use by issuing ./configure --help | grep extname
. Of course, you need to have the library itself available and may have to configure the path where it is located (depending on the extension and whether it is in the "default" path).