How can I decode json in PHP 5.1?

前端 未结 8 921
孤街浪徒
孤街浪徒 2020-12-16 20:10

json_decode function is not part of PHP 5.1, so I cannot use it. Is there any other function for this version?

8条回答
  •  囚心锁ツ
    2020-12-16 20:43

    You're seeing this error because you have a php version earlier than 5.2.0. These functions are included by default in php 5.2.0 and later.

    PHP Fatal error:  Call to undefined function json_encode()
    

    You can install the PECL extension by running:

    pecl install json
    

    It will compile, then add this to your php.ini file: (mine is in /etc/php5/apache2)

    extension=json.so
    

    Then restart apache.

提交回复
热议问题