note 106641 added to function.json-encode
| From: | bohwaz at osu1 dot php dot net | Date: | Thu, 24 Nov 2011 01:05:18 +0000 |
| Subject: | note 106641 added to function.json-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184646@lists.php.net to get a copy of this message | ||
Are you sure you want to use JSON_NUMERIC_CHECK, really really sure?
Just watch this usecase:
<?php
// International phone number
json_encode(array('phone_number' => '+33123456789'), JSON_NUMERIC_CHECK);
?>
And then you get this JSON:
{"phone_number":33123456789}
Maybe it makes sense for PHP (as is_numeric('+33123456789') returns true), but really,
casting it as an int?!
So be careful when using JSON_NUMERIC_CHECK, it may mess up with your data!
----
Server IP: 93.93.89.9
Probable Submitter: 109.190.6.11
----
Manual Page -- http://www.php.net/manual/en/function.json-encode.php
Edit -- https://master.php.net/note/edit/106641
Del: integrated -- https://master.php.net/note/delete/106641/integrated
Del: useless -- https://master.php.net/note/delete/106641/useless
Del: bad code -- https://master.php.net/note/delete/106641/bad+code
Del: spam -- https://master.php.net/note/delete/106641/spam
Del: non-english -- https://master.php.net/note/delete/106641/non-english
Del: in docs -- https://master.php.net/note/delete/106641/in+docs
Del: other reasons-- https://master.php.net/note/delete/106641
Reject -- https://master.php.net/note/reject/106641
Search -- https://master.php.net/manage/user-notes.php