note 108701 deleted from function.json-decode by googleguy
| From: | googleguy@php.net | Date: | Fri, 14 Jun 2013 10:04:39 +0000 |
| Subject: | note 108701 deleted from function.json-decode by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195216@lists.php.net to get a copy of this message | ||
Note Submitter: geoffrey dot hoffman at nospam dot gmail dot com
----
I thought I would advise you to be careful if using U.S. addresses, particularly five-digit zip
codes, with json_encode and json_decode.
The manual states that json_decode($data) will return $data in the appropriate PHP type. But it may
not be the type you stored!
In my case, I have some data that might be scalar (e.g. string containing "01234") or
might be a json packet (containing multiple zipcodes), and I was calling json_decode on everything.
<?php
$zip = "01234";
$test_zip = json_decode($zip);
echo $zip === $test_zip; // FALSE
?>
Because $test_zip is an integer containing 1234.