Bug #71451 [Opn->Nab]: var_export() wrong output
| From: | rasmus@php.net | Date: | Tue, 26 Jan 2016 13:47:25 +0000 |
| Subject: | Bug #71451 [Opn->Nab]: var_export() wrong output | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-198902@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71451&edit=1
ID: 71451
Updated by: rasmus@php.net
Reported by: nask0 at cod3r dot net
Summary: var_export() wrong output
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Fedora release 23 (Twenty Three)
PHP Version: 5.6.17
Block user comment: N
Private report: N
New Comment:
This is because var_export() is a serialization function and thus uses the serialization_precision
setting. Try this:
php -d serialize_precision=14 -r 'var_export(1.001); echo "\n" ;
var_dump(1.001);'
If you set your precision and serialize_precision to the same value you will get the same output
from var_dump() and var_export(). var_dump() is not a serialization function since its output
can't be read back in by anything. It is just for display purposes.
Previous Comments:
------------------------------------------------------------------------
[2016-01-26 08:15:17] nask0 at cod3r dot net
Description:
------------
var_export(1.001) outputs 1.0009999999999999 instead of 1.001
Test script:
---------------
Run in CLI :
php -r "var_export(1.001); echo \"\n\"; var_dump(1.001);"
Expected result:
----------------
1.001
double(1.001)
Actual result:
--------------
1.0009999999999999
double(1.001)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71451&edit=1