From owner-freebsd-questions@freebsd.org Fri Feb 1 06:41:34 2019 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2517414C54F6 for ; Fri, 1 Feb 2019 06:41:34 +0000 (UTC) (envelope-from srs0=bsve=qi=mail.sermon-archive.info=doug@sermon-archive.info) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 9D47D71AA2 for ; Fri, 1 Feb 2019 06:41:33 +0000 (UTC) (envelope-from srs0=bsve=qi=mail.sermon-archive.info=doug@sermon-archive.info) Received: by mailman.ysv.freebsd.org (Postfix) id 616D214C54F4; Fri, 1 Feb 2019 06:41:33 +0000 (UTC) Delivered-To: questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21AE214C54F2 for ; Fri, 1 Feb 2019 06:41:33 +0000 (UTC) (envelope-from srs0=bsve=qi=mail.sermon-archive.info=doug@sermon-archive.info) Received: from mail.sermon-archive.info (sermon-archive.info [71.177.216.148]) by mx1.freebsd.org (Postfix) with ESMTP id 201A071A94 for ; Fri, 1 Feb 2019 06:41:31 +0000 (UTC) (envelope-from srs0=bsve=qi=mail.sermon-archive.info=doug@sermon-archive.info) Received: from [10.0.1.251] (mini [10.0.1.251]) by mail.sermon-archive.info (Postfix) with ESMTPSA id 43rSDh5pG0z2fjQ7 for ; Thu, 31 Jan 2019 22:41:24 -0800 (PST) From: Doug Hardie Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Problems with JSON and PHP Message-Id: Date: Thu, 31 Jan 2019 22:41:24 -0800 To: questions@freebsd.org X-Mailer: Apple Mail (2.3445.102.3) X-Virus-Scanned: clamav-milter 0.100.2 at mail X-Virus-Status: Clean X-Rspamd-Queue-Id: 201A071A94 X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of srs0=bsve=qi=mail.sermon-archive.info=doug@sermon-archive.info designates 71.177.216.148 as permitted sender) smtp.mailfrom=srs0=bsve=qi=mail.sermon-archive.info=doug@sermon-archive.info X-Spamd-Result: default: False [1.44 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-0.24)[-0.240,0]; FROM_HAS_DN(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:71.177.216.148]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[questions@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; IP_SCORE(-0.02)[asn: 5650(-0.02), country: US(-0.07)]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MX_GOOD(-0.01)[sermon-archive.info]; NEURAL_SPAM_LONG(0.22)[0.224,0]; RCVD_IN_DNSWL_NONE(0.00)[148.216.177.71.list.dnswl.org : 127.0.10.0]; NEURAL_SPAM_SHORT(0.89)[0.886,0]; FORGED_SENDER(0.30)[bc979@lafn.org,srs0=bsve=qi=mail.sermon-archive.info=doug@sermon-archive.info]; RCVD_NO_TLS_LAST(0.10)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:5650, ipnet:71.177.216.0/23, country:US]; FROM_NEQ_ENVFROM(0.00)[bc979@lafn.org,srs0=bsve=qi=mail.sermon-archive.info=doug@sermon-archive.info]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 06:41:34 -0000 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 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