note 49285 deleted from function.serialize by aharvey
| From: | aharvey@php.net | Date: | Tue, 06 Nov 2012 02:07:36 +0000 |
| Subject: | note 49285 deleted from function.serialize by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191757@lists.php.net to get a copy of this message | ||
Note Submitter: gafunchal NOSPAN at inf dot ufrgs dot br
----
(please, excuse my poor English)
'serialize' does strange things with floats, this code:
$a = 3.14;
$s = serialize($a);
$fp = fopen("storage", "w");
fwrite($fp, $s);
fclose($fp);
outputs something like (PHP 5.0.2):
d:3.140000000000000124344978758017532527446746826171875;
I wonder why serialize doesn't store data (not only float, I mean all types of data) in a more
'economic' format. Maybe binary is not the best option (there can be trouble storing it in
databases), but there are still a lot of other possibilities.