0

I'm trying to call json_decode(). I'm using a shared Hostgator server. I have already checked some other questions on StackOverflow regarding "json_decode"

After ssh-ing in, php -v outputs the following:

PHP 7.4.16 (cli) (built: Mar  9 2021 17:55:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.4.5, Copyright (c) 2002-2020, by ionCube Ltd.

and when I search the PHP modules using php -m it does appear to have the line

json

in the output

Stevie G
  • 5,638
  • 1
  • 10
  • 16
  • 2
    Is the CLI PHP the same as the one served in the web server…? – deceze Mar 18 '21 at 05:31
  • Yes, running "ls" shows everything that the web-based file manager and FTP show. – Wade McGillis Mar 18 '21 at 05:32
  • 2
    Yeah, no, there might still be a disconnect. Put a .php file with ` – deceze Mar 18 '21 at 05:33
  • I have also already done that. PHP Version 7.4.16 and '--enable-json=shared' – Wade McGillis Mar 18 '21 at 05:36
  • 1
    ‘K, just making sure. – deceze Mar 18 '21 at 05:42
  • 1
    Does any of this help? https://stackoverflow.com/questions/18239405/php-fatal-error-call-to-undefined-function-json-decode – CBroe Mar 18 '21 at 07:49
  • 1
    When I connect via ssh, it is a readonly file system. I am not able to make changes to any files, or run any system console commands. Checking the ini path via ssh vs phpinfo results in different ini files, with phpinfo pointing to a php70 ini despite running php 7.4. Using cpanel's multiphp ini tool and rolling back the website to php 7.0 fixed the issue and json functions work now. I have no idea what is wrong with Hostgator's php configuration that causes json to fail with php 7.4 but the problem is "solved" now. "Solved" in that the functions are working for me, but the causes exists – Wade McGillis Mar 19 '21 at 02:33

1 Answers1

-1

Try this:

  1. Create a file in the servers web root called phpinfo.php and add the following to it:
<?php 

phpinfo(); 

?>

Go to phpinfo.php in your web browser to confirm that JSON is installed, and that the web server is using the same version of PHP as the CLI version.

Stevie G
  • 5,638
  • 1
  • 10
  • 16