From owner-freebsd-questions@freebsd.org Sat Feb 2 01:31:45 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 1BE4014C8CD5 for ; Sat, 2 Feb 2019 01:31:45 +0000 (UTC) (envelope-from srs0=jeug=qj=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 5B80B8DB12 for ; Sat, 2 Feb 2019 01:31:44 +0000 (UTC) (envelope-from srs0=jeug=qj=mail.sermon-archive.info=doug@sermon-archive.info) Received: by mailman.ysv.freebsd.org (Postfix) id 1BA6A14C8CC2; Sat, 2 Feb 2019 01:31:44 +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 D1E1514C8CC0 for ; Sat, 2 Feb 2019 01:31:43 +0000 (UTC) (envelope-from srs0=jeug=qj=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 389EE8DB06 for ; Sat, 2 Feb 2019 01:31:43 +0000 (UTC) (envelope-from srs0=jeug=qj=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 43rxJr5FVCz2fjPs; Fri, 1 Feb 2019 17:31:40 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: Problems with JSON and PHP From: Doug Hardie In-Reply-To: <0792A559-EDF6-49F2-889D-4D99762FD6EC@mail.sermon-archive.info> Date: Fri, 1 Feb 2019 17:31:40 -0800 Cc: Mark Moellering Content-Transfer-Encoding: quoted-printable Message-Id: <5B1444AE-5241-4422-B6BA-5CE138921701@mail.sermon-archive.info> References: <0792A559-EDF6-49F2-889D-4D99762FD6EC@mail.sermon-archive.info> 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: 389EE8DB06 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.98 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] 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: Sat, 02 Feb 2019 01:31:45 -0000 > On 1 February 2019, at 14:26, Doug Hardie wrote: >=20 >> On 1 February 2019, at 07:24, Mark Moellering = wrote: >>=20 >> On Fri, Feb 1, 2019 at 10:17 AM wrote: >>=20 >>>>> test# more /usr/local/www/apache24/data/test.php >>>>> >>>> print "Hello world"; >>>>>=20 >>>>> $myObj =3D (object) array(); >>>>> $myObj->name =3D "John"; >>>>> $myObj->age =3D 30; >>>>> $myObj->city =3D "New York"; >>>>>=20 >>>>> $myJSON =3D json_encode($myObj); >>>>>=20 >>>>> echo $myJSON; >>>>> ?> >>>>>=20 >>>>>=20 >>>>> I use php and my biggest complaint is the way it handles errors. = I >>> think >>>> what is happening is that your Object Definition has a syntax error = but >>> php >>>> is complaining about the json_encode. >>>> I believe (from the php.net docs) that it should be >>>>=20 >>>> $myObj =3D new stdClass(); >>>>> $myObj->name =3D "John"; >>>>> $myObj->age =3D 30; >>>>> $myObj->city =3D "New York"; >>>>>=20 >>>>=20 >>>=20 >>> Don=E2=80=99t believe that=E2=80=99s actually the issue, since the = supplied test.php works >>> like charm for me, either in my browser (through apache) or via = command >>> line. >>>=20 >>> If it were the declaration, the command line would fail as well. >=20 > The initial issue is with a very large package. The example I = provided was the simplest I could come up with that showed the issue. I = ran php -init and the output (partial) was: >=20 > Server API =3D> Command Line Interface > Virtual Directory Support =3D> disabled > Configuration File (php.ini) Path =3D> /usr/local/etc > Loaded Configuration File =3D> /usr/local/etc/php.ini > Scan this dir for additional .ini files =3D> /usr/local/etc/php > Additional .ini files parsed =3D> = /usr/local/etc/php/ext-18-session.ini, > /usr/local/etc/php/ext-20-curl.ini, > /usr/local/etc/php/ext-20-filter.ini, > /usr/local/etc/php/ext-20-gd.ini, > /usr/local/etc/php/ext-20-hash.ini, > /usr/local/etc/php/ext-20-json.ini, > /usr/local/etc/php/ext-20-mbstring.ini, > /usr/local/etc/php/ext-20-mcrypt.ini, > /usr/local/etc/php/ext-20-mysqli.ini, > /usr/local/etc/php/ext-20-openssl.ini, > /usr/local/etc/php/ext-20-xdebug.ini, > /usr/local/etc/php/ext-20-xml.ini, > /usr/local/etc/php/ext-20-zip.ini, > /usr/local/etc/php/ext-20-zlib.ini >=20 > running via the web server the info.php file gives (reformatted to = look like the above): >=20 > Configuration File (php.ini)=20 > Path /usr/local/etc > Loaded Configuration File /usr/local/etc/php.ini > Scan this dir for additional .ini files /usr/local/etc/php > Additional .ini files parsed=09 > /usr/local/etc/php/ext-18-session.ini,=20 > /usr/local/etc/php/ext-20-curl.ini,=20 > /usr/local/etc/php/ext-20-filter.ini,=20 > /usr/local/etc/php/ext-20-gd.ini,=20 > /usr/local/etc/php/ext-20-hash.ini,=20 > /usr/local/etc/php/ext-20-json.ini,=20 > /usr/local/etc/php/ext-20-mbstring.ini,=20 > /usr/local/etc/php/ext-20-mcrypt.ini,=20 > /usr/local/etc/php/ext-20-mysqli.ini,=20 > /usr/local/etc/php/ext-20-openssl.ini,=20 > /usr/local/etc/php/ext-20-xdebug.ini,=20 > /usr/local/etc/php/ext-20-xml.ini,=20 > /usr/local/etc/php/ext-20-zip.ini,=20 > /usr/local/etc/php/ext-20-zlib.ini >=20 > They both use the same ini file for json. I don't see any differences = between them. I found the problem. The following lines were missing in http.conf: SetHandler application/x-httpd-php SetHandler application/x-httpd-php-source Somehow during the installation process that file got replaced by a = generic copy and those lines vanished. The way I found that was by = setting up yet another test server and it worked. Then compared the = various config files.=