Home > Article > Backend Development > Why does PHP throw a \"Call to undefined function json_decode()\" error, even with a version greater than 5.1?
The PHP error "Call to undefined function json_decode()" indicates that the JSON parsing function is not recognized by PHP. Despite the reported PHP version being higher than 5.1, which includes JSON support, this error may still occur.
In Debian-based systems, including Ubuntu, the standard JSON extension has been removed from PHP 5.5rc2 due to a licensing conflict. Debian requires all packaged software to comply with the Debian Free Software Guidelines (DFSG).
The original JSON license contains a clause that restricts its use for "Good, not Evil." This conflicts with the DFSG's definition of free software, which requires the freedom to run the program for any purpose. As such, Debian considers the JSON license to be nonfree.
Debian has replaced the standard JSON extension with a functionally equivalent replacement that complies with the DFSG. To resolve the "json_decode()" error, Debian users need to install the appropriate replacement extension for their PHP version:
After installing the required extension, it's crucial to restart Apache or PHP-FPM to activate the changes:
The above is the detailed content of Why does PHP throw a \"Call to undefined function json_decode()\" error, even with a version greater than 5.1?. For more information, please follow other related articles on the PHP Chinese website!