Enable json_encode in PHP

后端 未结 4 1266
予麋鹿
予麋鹿 2020-12-11 16:08

Could someone advise on how to enable the json_encode function in PHP?

I have a clean install of Centos 5.6 and have just installed Virtualmin.

Does anyone k

4条回答
  •  隐瞒了意图╮
    2020-12-11 16:53

    On CenotOS and other *nix systems, even if you have PHP compiled with --disable-json not everything may be lost. The first thing of course is to check output from your phpinfo(); and search for occurrences of json. If you see json support enabled then of course you have json extension enabled, but if not, see if you have /etc/php.d/json.ini listed in Additional .ini files parsed. If you do, then this file may look like this:

    ; Enable json extension module
    ;extension=json.so

    Uncomment the second line and restart your Apache. If Apache started without errors, check your phpinfo() again and see if this enabled your json extension. If if did, you're all set, if not, you may have to find the directory where your php extensions are located and if you see json.so in there, edit the last line to include the full path to that file and restart Apache again. If you don't have json.so file with your other php extension files, you probably will have to recompile that one extension (you don't need to recompile your whole PHP, but you certainly could, this time with --enable-json), and then try again.

    Also, if you don't have additional .ini files parsed, you can try adding this extension in your main php.ini, which is usually /etc/php.ini.

提交回复
热议问题