note 117804 added to function.json-decode

From: Date: Wed, 12 Aug 2015 12:55:39 +0000
Subject: note 117804 added to function.json-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-203320@lists.php.net to get a copy of this message
I have noticed change in behaviour between 5.5.25 and 5.5.27: On 5.5.25 we have: [lluczak]$ php -v PHP 5.5.25 (cli) (built: May 16 2015 07:23:58) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans [lluczak@llpc fcc]$ php -a Interactive shell php > $str = '[NULL]'; php > echo ($str); [NULL] php > print_r(json_decode($str,true)); Array ( [0] => ) php > var_dump(json_decode($str,true)); array(1) { [0] => NULL } But on 5.5.27 we have [root@coin tmp]# php -v PHP 5.5.27 (cli) (built: Jul 10 2015 23:40:40) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies [root@coin tmp]# php -a Interactive shell php > $str = '[NULL]'; php > echo ($str); [NULL] php > print_r(json_decode($str,true)); php > var_dump(json_decode($str,true)); NULL php > You can notice that for '[NULL]', php 5.5.25 returns array with one element which is null but php 5.5.27 returns null. If you provide '[null]' then it works well on both versions. In changelog there is mentioned that at 5.6.0 there is "Invalid non-lowercased variants of the true, false and null literals are no longer accepted as valid input, and will generate warnings. " but in fact it works also for 5.5.27 ---- Server IP: 72.52.91.14 Probable Submitter: 194.28.49.229 ---- Manual Page -- http://php.net/manual/en/function.json-decode.php Edit -- https://master.php.net/note/edit/117804 Del: integrated -- https://master.php.net/note/delete/117804/integrated Del: useless -- https://master.php.net/note/delete/117804/useless Del: bad code -- https://master.php.net/note/delete/117804/bad+code Del: spam -- https://master.php.net/note/delete/117804/spam Del: non-english -- https://master.php.net/note/delete/117804/non-english Del: in docs -- https://master.php.net/note/delete/117804/in+docs Del: other reasons-- https://master.php.net/note/delete/117804 Reject -- https://master.php.net/note/reject/117804 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203320) next »