Problem:
Users may encounter the PHP fatal error "Call to undefined function json_decode()" even while they're running PHP versions greater than 5.1.
Solution:
If you're using Ubuntu, this issue may be related to a license conflict that prompted Debian to remove the original JSON extension in PHP 5.5rc2.
To resolve this, install the replacement extension appropriate for your PHP version:
sudo apt-get install php7.2-json
(Replace "7.2" with the version you're using, e.g., php5-json for PHP 5.5.)
Additionally, restart Apache or PHP-FPM:
sudo service apache2 restart
or
sudo service php7.2-fpm restart
Explanation:
The JSON license's "use for Good, not Evil" clause clashed with the Free Software Foundation's definition of free software. Consequently, Debian removed the JSON extension and provided a replacement functional equivalent.
Note:
The above is the detailed content of Why Am I Getting \'Call to undefined function json_decode()\' in PHP 5.5 on Ubuntu?. For more information, please follow other related articles on the PHP Chinese website!