note 115733 added to function.json-encode

From: Date: Mon, 15 Sep 2014 09:48:39 +0000
Subject: note 115733 added to function.json-encode
Groups: php.notes 
Request: Send a blank email to php-notes+get-200446@lists.php.net to get a copy of this message
Although this is not documented on the version log here, non-UTF8 handling behaviour has changed in 5.5, in a way that can make debugging difficult. Passing a non UTF-8 string to json_encode() will make the function return false in PHP 5.5, while it will only nullify this string (and only this one) in previous versions. In a Latin-1 encoded file, write this: <?php $a = array('é', 1); var_dump(json_encode($a)); ?> PHP < 5.4: string(8) "[null,1]" PHP >= 5.5: bool(false) PHP 5.5 has it right of course (if encoding fails, return false) but its likely to introduce errors when updating to 5.5 because previously you could get the rest of the JSON even when one string was not in UTF8 (if this string wasn't used, you'd never notify it's nulled) ---- Server IP: 72.52.91.14 Probable Submitter: 2001:41d0:fe6a:3200:bdd0:249a:b5a6:3e03 ---- Manual Page -- http://php.net/manual/en/function.json-encode.php Edit -- https://master.php.net/note/edit/115733 Del: integrated -- https://master.php.net/note/delete/115733/integrated Del: useless -- https://master.php.net/note/delete/115733/useless Del: bad code -- https://master.php.net/note/delete/115733/bad+code Del: spam -- https://master.php.net/note/delete/115733/spam Del: non-english -- https://master.php.net/note/delete/115733/non-english Del: in docs -- https://master.php.net/note/delete/115733/in+docs Del: other reasons-- https://master.php.net/note/delete/115733 Reject -- https://master.php.net/note/reject/115733 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200446) next »