Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Feb 2019 14:26:13 -0800
From:      Doug Hardie <bc979@lafn.org>
To:        questions@freebsd.org
Cc:        Mark Moellering <markmoellering@psyberation.com>
Subject:   Re: Problems with JSON and PHP
Message-ID:  <0792A559-EDF6-49F2-889D-4D99762FD6EC@mail.sermon-archive.info>
In-Reply-To: <CAA0uU3XR4LMBdHzTFq0tmdHmKzpsSO9F_AuMoryBrTA0%2BG2%2BFw@mail.gmail.com>
References:  <C71BB378-7DC7-4C6B-83AE-21C44BA240EE@mail.sermon-archive.info> <CAA0uU3VJLXetWaeVr1CntGAnjFOyWQj0EyjB-W1ri3nJCHXeAA@mail.gmail.com> <BA63BD50-B678-4B72-82B3-8800E9C210F3@boosten.org> <CAA0uU3XR4LMBdHzTFq0tmdHmKzpsSO9F_AuMoryBrTA0%2BG2%2BFw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> On 1 February 2019, at 07:24, Mark Moellering =
<markmoellering@psyberation.com> wrote:
>=20
> On Fri, Feb 1, 2019 at 10:17 AM <freebsd@boosten.org> wrote:
>=20
>>>> test# more /usr/local/www/apache24/data/test.php
>>>> <?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.

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:

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

running via the web server the info.php file gives (reformatted to look =
like the above):

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

They both use the same ini file for json.  I don't see any differences =
between them.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0792A559-EDF6-49F2-889D-4D99762FD6EC>