Date: Thu, 31 Jan 2019 22:41:24 -0800 From: Doug Hardie <bc979@lafn.org> To: questions@freebsd.org Subject: Problems with JSON and PHP Message-ID: <C71BB378-7DC7-4C6B-83AE-21C44BA240EE@mail.sermon-archive.info>
next in thread | raw e-mail | index | archive | help
I have installed apache24, php72 and a host of other somewhat related = php packages. I can't seem to get apache to run a php script that = includes json_encode. test# pkg info | grep php mod_php72-7.2.14 PHP Scripting Language php72-7.2.14 PHP Scripting Language php72-curl-7.2.14 The curl shared extension for php php72-filter-7.2.14 The filter shared extension for php php72-gd-7.2.14 The gd shared extension for php php72-hash-7.2.14 The hash shared extension for php php72-json-7.2.14 The json shared extension for php php72-mbstring-7.2.14 The mbstring shared extension for php php72-mysqli-7.2.14 The mysqli shared extension for php php72-openssl-7.2.14 The openssl shared extension for php php72-pear-1.10.6 PEAR framework for PHP php72-pear-Services_JSON-1.0.3 PHP implementation of json_encode/decode php72-pecl-mcrypt-1.0.1 PHP extension for mcrypt, removed in PHP = 7.2 php72-pecl-xdebug-2.6.1 Xdebug extension for PHP php72-session-7.2.14 The session shared extension for php php72-xml-7.2.14 The xml shared extension for php php72-zip-7.2.14 The zip shared extension for php php72-zlib-7.2.14 The zlib shared extension for php test# pkg info | grep apache apache24-2.4.38 Version 2.4.x of Apache web server test# pkg info | grep mod_ mod_php72-7.2.14 PHP Scripting Language Server has been rebooted several times. test# freebsd-version -ku 12.0-RELEASE 12.0-RELEASE In /usr/local/www/apache24/data is the file: test# more /usr/local/www/apache24/data/test.php <?php print "Hello world"; $myObj =3D (object) array(); $myObj->name =3D "John"; $myObj->age =3D 30; $myObj->city =3D "New York"; $myJSON =3D json_encode($myObj); echo $myJSON; ?> Running it by hand works: test# php /usr/local/www/apache24/data/test.php Hello world{"name":"John","age":30,"city":"New York"}test#=20 Accessing it via a browser yields: Hello world and an error: test# tail -1 /var/log/httpd-error.log [Thu Jan 31 22:29:25.506018 2019] [php7:error] [pid 1586] [client = 10.0.1.251:53459] PHP Fatal error: Uncaught Error: Call to undefined = function json_encode() in /usr/local/www/apache24/data/test.php:9\nStack = trace:\n#0 {main}\n thrown in /usr/local/www/apache24/data/test.php on = line 9 The info.php file in that directory works properly when accessed via the = browser. Obviously I have got something setup wrong. I have not been = able to figure it out. ktrace never shows any attempt to access = anything I can see identifiable with json_encode. I would appreciate = any ideas on how to fix this. Thanks -- Doug
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C71BB378-7DC7-4C6B-83AE-21C44BA240EE>