json seem enable but cannot run json_encode

前端 未结 3 1385
生来不讨喜
生来不讨喜 2020-12-22 04:35

My PHP version is 5.1.6 I have install Json by follow the instructions:

# yum install php-devel
# yum install php-pear
# yum install gcc
# pear install json
         


        
相关标签:
3条回答
  • 2020-12-22 04:56

    From Let's Install JSON for PHP 5

    Install json - This was actually trickier than expected. I assumed I would be able to install this via pear. Apparently, a PEAR Services_JSON package was developed, but it has never been accepted into the official repository. The trick instead is to use the PECL json package. This was as easy as running pecl install json and watching the compiler do its thing. When it's done you should have a json.so file in your PHP modules directory. (Mine is /usr/lib/php/modules/.)

    0 讨论(0)
  • 2020-12-22 05:00

    If your var_dump( function_exists( 'json_encode' ) ) returns true, while your HTTP request says the function doesn't exist; there's only one explanation I can think of: CLI and HTTP requests use a different php.ini. In your phpinfo( ) document, it says that it's loading json.ini, but I don't see any other reference to JSON in there.

    Check your logs to see whether or not json.so is actually loaded upon a HTTP request. My bet is that it isn't.

    0 讨论(0)
  • 2020-12-22 05:01

    Granted, this is an old topic, but maybe someone will stumble across this like I did in August 2015. I fixed this by changing the extensions folder path in php.ini. It was somehow set to "./" and not /usr/lib64/php/modules/

    0 讨论(0)
提交回复
热议问题