Wednesday, February 17, 2010

Solved: PHP Fatal error: Call to undefined function json_encode(), How to Install JSON in PHP

PHP 5.2 has included inbuilt json_encode() and json_decode() functions by default. Using any version prior to PHP 5.2 doesn't have native JSON support. You need to compile and install json.

JSON stands for "JavaScript Object Notation" is a lightweight data-interchange format. For More Information in JSON Visit JSON Website

Error : "PHP Fatal error: Call to undefined function json_encode()"

How to install JSON in 2 easy steps.
1. Use PECL JSON Package. Log in as root and run the command
root# pecl install json
This will compile the JSON package.
2. Create a file named json.in in /etc/php.d or Check the Module Location in php.ini. Add extension=json.so to the file, and you are done
root#touch /etc/php.d/json.ini
root# echo "extension=json.so" > /etc/php.d/json.in

Restart Apache and run you application.
root# service httpd restart

You have successfully installed JSON.

No comments:

Post a Comment