NotionCommotion Posted June 25, 2017 Share Posted June 25, 2017 The following script produces the following results when run on the two machines: <?php $json=''; $obj=json_decode($json); $error=json_last_error(); $version=phpversion(); echo("$version | $error"); 5.6.30 | 0 7.1.6 | 4 http://php.net/manual/en/function.json-decode.php tells me: 7.1.0 An empty JSON key ("") can be encoded to the empty object property instead of using a key with value _empty_. 7.0.0 An empty PHP string or value that after casting to string is an empty string (NULL, FALSE) results in JSON syntax error. How do you interpreter these two lines? Quote Link to comment Share on other sites More sharing options...
requinix Posted June 25, 2017 Share Posted June 25, 2017 Take a look. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted June 25, 2017 Author Share Posted June 25, 2017 Yes, I had those same results. I just misread this line, and thought they were saying it wasn't an error: 7.1.0 An empty JSON key ("") can be encoded to the empty object property instead of using a key with value _empty_. Quote Link to comment Share on other sites More sharing options...
requinix Posted June 25, 2017 Share Posted June 25, 2017 Right. It's a change in behavior: before they were using "_empty_" so that people could access it easily, $object->_empty_but with the complex {} syntax becoming more and more well known (especially when it comes to decoding a JSON object) PHP stopped "fixing" the key so that $object->{""}would work as expected. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted June 25, 2017 Author Share Posted June 25, 2017 Change in behavior always takes me for a loop! Quote Link to comment Share on other sites More sharing options...
requinix Posted June 26, 2017 Share Posted June 26, 2017 There was a good reason behind the old behavior, but that's true for register_globals and magic_quotes too. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.