Re: json_encode() behavior for incorrectly encoded strings

From: Date: Sun, 24 Jun 2012 15:39:48 +0000
Subject: Re: json_encode() behavior for incorrectly encoded strings
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-60957@lists.php.net to get a copy of this message
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.

« previous php.internals (#60957) next »