Date: Fri, 1 Feb 2019 16:17:38 +0100 From: freebsd@boosten.org To: Mark Moellering <markmoellering@psyberation.com> Cc: Doug Hardie <bc979@lafn.org>, questions@freebsd.org Subject: Re: Problems with JSON and PHP Message-ID: <BA63BD50-B678-4B72-82B3-8800E9C210F3@boosten.org> In-Reply-To: <CAA0uU3VJLXetWaeVr1CntGAnjFOyWQj0EyjB-W1ri3nJCHXeAA@mail.gmail.com> References: <C71BB378-7DC7-4C6B-83AE-21C44BA240EE@mail.sermon-archive.info> <CAA0uU3VJLXetWaeVr1CntGAnjFOyWQj0EyjB-W1ri3nJCHXeAA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
>> 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 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. If it were the declaration, the command line would fail as well. Peter
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BA63BD50-B678-4B72-82B3-8800E9C210F3>