Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60984 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87077 invoked from network); 27 Jun 2012 11:30:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2012 11:30:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:34350] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/83-02132-9DEEAEF4 for ; Wed, 27 Jun 2012 07:30:34 -0400 Received: by lbgc1 with SMTP id c1so1691287lbg.29 for ; Wed, 27 Jun 2012 04:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=veCPB+gMAUamJRiuTaC1ysG24/U23eIB0cJfElgaKYk=; b=WUfj7NY+nmNLbCKVlpERZCF6i9mJ+lgeDFTONhA/e+AwKwujaUlJXkEpyTjP4dk9Uy hyR1vOPk9iGW5c1rbhnHy0yO/HmRYMJFvBFPp3CjEBnhdcVf6/ut9HuadoxokJlTPxQF R91mVG7swNgaTQAek2TwksM3cKvW1H7OKICXQImZOsfG4rEHiiXNz0iP2vvLyUSPDDVL Xj10OIVUiC1NMOUe0M+apgt+FNFIFB9MdWriyoyzblB61WiPXJZCc6jCNeCefTT2KrzE IMva0yxuVWKN4SxiyF+8Il4UVhjVVcM9DZzZXwd8yQdrePp0yF4soHMKfWPHTCpeeINe NC1w== MIME-Version: 1.0 Received: by 10.112.17.200 with SMTP id q8mr9202283lbd.11.1340796630658; Wed, 27 Jun 2012 04:30:30 -0700 (PDT) Received: by 10.152.114.70 with HTTP; Wed, 27 Jun 2012 04:30:30 -0700 (PDT) In-Reply-To: References: <20120621141241.GA25789@analysisandsolutions.com> <4FE33EDF.2000409@lerdorf.com> <4FE61E9D.5050908@sugarcrm.com> <4FE734C4.2010706@lerdorf.com> <4FEA489D.1010601@sugarcrm.com> Date: Wed, 27 Jun 2012 13:30:30 +0200 Message-ID: To: Benjamin Eberlei Cc: Stas Malyshev , Rasmus Lerdorf , Gustavo Lopes , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] json_encode() behavior for incorrectly encoded strings From: nikita.ppv@googlemail.com (Nikita Popov) On Wed, Jun 27, 2012 at 1:27 PM, Benjamin Eberlei wrote: > > On Wed, Jun 27, 2012 at 1:41 AM, Stas Malyshev > wrote: >> >> Hi! >> >> > Makes sense to me. So should I do this? Remove warnings + add string >> > parameter for json_last_error? > > > I think its weird that the parameter is called $error_string and setting it > to true means returning an array. > > Why not in the spirit of others have a new function json_last_error_msg() or > something similar? I implemented it with json_last_error(true) returning just a string, not an array. You can get the array using array(json_last_error(), json_last_error(true)) if you really want. But usually you will only need one of them as they both have different use cases. The stringified version for debugging and the error code version for detecting the error programmatically. Nikita