From owner-freebsd-questions@freebsd.org Fri Feb 1 15:17:54 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 96FE914B68BF for ; Fri, 1 Feb 2019 15:17:54 +0000 (UTC) (envelope-from freebsd@boosten.org) 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 C8E6E6C7C7 for ; Fri, 1 Feb 2019 15:17:49 +0000 (UTC) (envelope-from freebsd@boosten.org) Received: by mailman.ysv.freebsd.org (Postfix) id 8793414B68B9; Fri, 1 Feb 2019 15:17:49 +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 7536114B68B8 for ; Fri, 1 Feb 2019 15:17:49 +0000 (UTC) (envelope-from freebsd@boosten.org) Received: from smtpq1.mnd.mail.iss.as9143.net (smtpq1.mnd.mail.iss.as9143.net [212.54.34.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0B2FE6C7C6 for ; Fri, 1 Feb 2019 15:17:48 +0000 (UTC) (envelope-from freebsd@boosten.org) Received: from [212.54.34.117] (helo=smtp9.mnd.mail.iss.as9143.net) by smtpq1.mnd.mail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1gpaZY-0001nx-CK; Fri, 01 Feb 2019 16:17:40 +0100 Received: from 5419f71f.cm-5-2d.dynamic.ziggo.nl ([84.25.247.31] helo=ra.boosten.org) by smtp9.mnd.mail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1gpaZY-0001RB-Ac; Fri, 01 Feb 2019 16:17:40 +0100 Received: from anubis.boosten.org (anubis.boosten.org [192.168.13.33]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ra.boosten.org (Postfix) with ESMTPSA id AB3FC3432F71; Fri, 1 Feb 2019 16:17:39 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: Problems with JSON and PHP From: freebsd@boosten.org In-Reply-To: Date: Fri, 1 Feb 2019 16:17:38 +0100 Cc: Doug Hardie , questions@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Mark Moellering X-Mailer: Apple Mail (2.3124) X-SourceIP: 84.25.247.31 X-Ziggo-spambar: / X-Ziggo-spamscore: 0.0 X-Ziggo-spamreport: CMAE Analysis: v=2.3 cv=WaVylHpX c=1 sm=1 tr=0 a=JWBJsaPp29SgP5DpYRBqZw==:17 a=IkcTkHD0fZMA:10 a=CFTnQlWoA9kA:10 a=67BIL_jfAAAA:8 a=FpYyrf4h4hoR8MdwYdEA:9 a=QEXdDO2ut3YA:10 X-Ziggo-Spam-Status: No X-Spam-Status: No X-Spam-Flag: No X-Rspamd-Queue-Id: 0B2FE6C7C6 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.982,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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 15:17:54 -0000 >> 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 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