Home  >  Article  >  Backend Development  >  Why Am I Getting \'Call to undefined function json_decode()\' in PHP 5.5 on Ubuntu?

Why Am I Getting \'Call to undefined function json_decode()\' in PHP 5.5 on Ubuntu?

Patricia Arquette
Patricia ArquetteOriginal
2024-10-29 03:25:29269browse

Why Am I Getting

PHP: Undefined Function 'json_decode()' Despite Running PHP 5.5

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:

  • PHP has not eliminated JSON support.
  • This issue only affects package management tools.

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!

Statement:
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