Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60957 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20728 invoked from network); 24 Jun 2012 15:39:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jun 2012 15:39:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.160.42 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:61908] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/B0-13635-9C437EF4 for ; Sun, 24 Jun 2012 11:39:54 -0400 Received: by pbbrp12 with SMTP id rp12so6077851pbb.29 for ; Sun, 24 Jun 2012 08:39:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding:x-gm-message-state; bh=Bia9PYJX5QXoEekYu0Pg0BTWM7efCDxN0YY+ukyEg7c=; b=AToNSv/hQB1P59XVZqzytMcTsO+V1c8Qoox39vXUBBGBspLQz2V4TUEPpu8SF5zy4i KoixnID+6btSB1ttkDL78hGPm1Uw2rHz7laHxwzjOcCRftHNGrQUNfBAUKmxxtA3OLca PKKtzOmy+etMt0Juna9ORS9/BZAFnHI5CHqazZeGkdau7n9xYKq0Nfr0kIN2rYnx05k7 SW9mPH3NR78bfPgHYNFcVC1znVdmgNPJ/dhugF/gzr+reaAb9h6R4GDCiAjM/8AgtL4+ +sScbJBW5+yL8onBvEYhti15ZnAAOcVxMhCiENMOwDueyVf+ddvlEUtCNJMg/C7parzl hKsQ== Received: by 10.68.239.9 with SMTP id vo9mr31505147pbc.41.1340552390632; Sun, 24 Jun 2012 08:39:50 -0700 (PDT) Received: from [192.168.200.5] (c-50-131-44-225.hsd1.ca.comcast.net. [50.131.44.225]) by mx.google.com with ESMTPS id sy3sm5623869pbc.18.2012.06.24.08.39.49 (version=SSLv3 cipher=OTHER); Sun, 24 Jun 2012 08:39:49 -0700 (PDT) Message-ID: <4FE734C4.2010706@lerdorf.com> Date: Sun, 24 Jun 2012 08:39:48 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Nikita Popov CC: Gustavo Lopes , internals@lists.php.net References: <20120621141241.GA25789@analysisandsolutions.com> <4FE33EDF.2000409@lerdorf.com> <4FE61E9D.5050908@sugarcrm.com> In-Reply-To: X-Enigmail-Version: 1.5pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnfKhXcG9aTBdqgHy20Ws8/XLsyNl102efvpQzaukKYXfMlfLSbUpzYr4qKqMj5CuN2oMlt Subject: Re: [PHP-DEV] json_encode() behavior for incorrectly encoded strings From: rasmus@lerdorf.com (Rasmus Lerdorf) On 06/24/2012 05:12 AM, Nikita Popov wrote: > The main problem with not throwing a warning is that it makes > debugging the error quite hard. json_last_error() only gives you an > error code. So you have to use some script like the one used as an > example in php.net/json_last_error to figure out what the particular > error code actually means. This is obviously a lot more inconvenient > than simply seeing "Oh, this failed because I passed an Inf". So how about: mixed json_last_error ( [bool $error_string = false] ) Returns the last error (if any) occurred during the last JSON encoding/decoding. By default an integer constant from the table below is returned. If $error_string is true, an array containing both the error constant and a string representation of the error is returned.