Why am I getting the \'Call to undefined function json_decode()\' error even though my PHP version is greater than 5.1?

Barbara Streisand
Release: 2024-10-30 04:45:28
Original
585 people have browsed it

Why am I getting the

PHP Fatal Error: Call to Undefined Function json_decode()

Problem Description:

PHP is throwing a fatal error "Call to undefined function json_decode()" despite php --version indicating a PHP version greater than 5.1, which should include JSON support.

Answer:

Using Ubuntu?

  • Install the appropriate PHP JSON module:

    • sudo apt-get install php7.2-json (or php7.1-json or php5-json)
  • Restart Apache or PHP-FPM:

    • sudo service apache2 restart (or php7.2-fpm restart)

Explanation:

  • Debian has removed the previous JSON extension in PHP 5.5rc2 due to a license conflict.
  • A functionally equivalent replacement extension is now offered.
  • PHP itself has not removed JSON support, and it remains built-in.
  • This issue is specific to distro packaging, which is not controlled by PHP.

Additional Details:

  • [Iteration99: PHP, JSON Licensing, and PHP 5.5](http://iteration99.com/2013/php-json-licensing-and-php-5-5/)
  • [Bye Bye Non-Free PHP JSON Extension](http://liorkaplan.wordpress.com/2013/06/01/bye-bye-non-free-php-json-extension/)
  • [Bug Report in PHP](https://bugs.php.net/bug.php?id=63520)
  • [Phil Sturgeon Blog: FUD Cracker](http://philsturgeon.co.uk/blog/2013/08/fud-cracker-php-55-never-lost-json-support)

The above is the detailed content of Why am I getting the \'Call to undefined function json_decode()\' error even though my PHP version is greater than 5.1?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!