My PHP version is 5.1.6 I have install Json by follow the instructions:
# yum install php-devel
# yum install php-pear
# yum install gcc
# pear install json
# cd /etc/php.d
# echo "extension=json.so" > json.ini
# service httpd restart
Now, I check that Json enabled, but I cannot run json_encode:
Check 1:
[root@69-64-69-43 ~]# php -i | grep json
Result 1:
/etc/php.d/json.ini,
json
json support => enabled
json version => 1.2.1
Check 2:
[root@69-64-69-43 ~]# php -r 'var_dump(function_exists("json_encode"));'
Result 2:
bool(true)
But when run:
Fatal error: Call to undefined function json_encode() in /var/www/vhosts/ykite.com/httpdocs/fre/json.php on line 8
Here is run link:
Check Json: http://69.64.69.43/fre/json.php
php_info(): http://69.64.69.43/fre/info.php
I was really looking and read many documents but I can not find the cause of this case.
I sincerely appreciate your help.
Cuong
If your var_dump( function_exists( 'json_encode' ) )
returns true, while your HTTP request says the function doesn't exist; there's only one explanation I can think of: CLI and HTTP requests use a different php.ini. In your phpinfo( )
document, it says that it's loading json.ini, but I don't see any other reference to JSON in there.
Check your logs to see whether or not json.so is actually loaded upon a HTTP request. My bet is that it isn't.