tags:

views:

26

answers:

3

Ok I am running CentOS, with PHP 5.2. I recently added the JSON extension. When running

php -i

.. after installing JSON, it says

json

json support => enabled
json version => 1.2.1

But when I run phpinfo it's not showing the JSON extension as being enabled. I have added the extension to the php.ini file so it loads the json.so file.

I am so confused about this. What could the possible causes of this be?

btw. I am running php as an apache module.

+3  A: 

Probably your PHP cli is using a different php.ini file, one that loads the json extension, and the Apache module isn't. php -i and phpinfo() give information about the loaded php.ini files.

For PHP cli, the php.ini location can be specified through the PHPRC environment variable or with php -c <file|dir>. For the Apache module, you can use the Apache directive PHPINIDir.

Artefacto
+1  A: 

As of PHP 5.2 the JSON extension is included in the core, you don't need to include any extensions. If it says JSON support is enabled it should work. Have you actually tried it?

As long as php wasn't compiled with --disable-json.

Kyprus
You'd be surprised on how often distributions remove extensions from the core. Besides, even if it's in the core, it should show up in `phpinfo`. It could also have been compiled with `--enable-json=shared`.
Artefacto
+1  A: 

Solved it guys. I added an updated repository, and ran yum update php I made the wrong mistake of assuming I was using 5.2 when infact it was 5.1

After the update it worked.

Jack Hayes