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"; >> >> $myObj = (object) array(); >> $myObj->name = "John"; >> $myObj->age = 30; >> $myObj->city = "New York"; >> >> $myJSON = json_encode($myObj); >> >> echo $myJSON; >> ?> >> >> >> 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 > > $myObj = new stdClass(); >> $myObj->name = "John"; >> $myObj->age = 30; >> $myObj->city = "New York"; >> > Don’t believe that’s 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>
