Re: json_encode() bug

From: Date: Fri, 01 Feb 2008 20:06:49 +0000
Subject: Re: json_encode() bug
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-35070@lists.php.net to get a copy of this message
Stupid question, who actually checks for E_* in his code at runtime after having called such functions? Not me and I would hate to. It sounds to me like a perfect exception use case. As this function can
General policy in PHP as far as I know is that non-OO functions do not do exceptions.
return nearly everything scalar we have (boolean, string, null, integer,...) we can't use our normal "returns FALSE on failure".
This function can return only a string, but I'm not sure returning false if somewhere in some value deep down your data is some bad utf-8 is warranted. It is doable, though, but I'm afraid most of current code never check for return of json_encode() so they are in for big surprises when json_encode won't produce valid JSON. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#35070) next »