|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41909 var_export
Submitted: 2007-07-05 17:11 UTC Modified: 2007-07-05 21:13 UTC
From: stingbat at stingbat dot dk Assigned:
Status: Closed Package: Variables related
PHP Version: 5.2.3 OS: Windows
Private report: No CVE-ID: None
 [2007-07-05 17:11 UTC] stingbat at stingbat dot dk
Seems like there has been a change to the var_export-function, when comparing PHP4 and PHP5, as stated below:

     314                 :         case IS_DOUBLE:
     315               8 :                 php_printf("%.*G", (int) EG(precision), Z_DVAL_PP(struc));
> from:

     407                 :         case IS_DOUBLE:
     408              42 :                 php_printf("%.*H", (int) EG(precision), Z_DVAL_PP(struc));
> from:

Of some reason, the output don't give the same.
I don't know if it's PHP4 that has always had this problem, or if it's a new problem only existing in PHP5.

However, it gives difficulties, if trying to compare the results or want to output the results float-values to either JavaScript or Database. And especially when trying to create scripts that should work on both PHP-versions (4.x+5.x).

Reproduce code:
	$test_value = 1.50;

	setlocale(LC_ALL, 'da_DK.iso-8859-1', 'da_DK', 'danish', 'da');
	echo 'DK: ' . var_export($test_value, TRUE) . "\n";

	setlocale(LC_ALL, 'en');
	echo 'EN: ' . var_export($test_value, TRUE) . "\n";

	echo "\n" . PHP_VERSION;

Expected result:
DK: 1.5
EN: 1.5

Actual result:
DK: 1,5
EN: 1.5


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-05 17:33 UTC]
Please try using this CVS snapshot:
For Windows (zip):

For Windows (installer):

I already fixed this I think... please try the snapshot. But are you really on Windows?
 [2007-07-05 20:31 UTC] stingbat at stingbat dot dk
Has it just been fixed?
Wasn't able to find any bug related to this issue, but could just see that there was a problem with PHP 5.2.3 (on multiple both Windows 2000 and XP).

Seems like it is fixed in the CVS snapshot, as far as I can see.

Thanks for the quick reply :)

Do you know in how many version of PHP5, the issue has existed?
 [2007-07-05 20:52 UTC]
5.2.1 to 5.2.3 only, I didn't file a bug for this, but I will write this one in the NEWS file.
 [2007-07-05 21:13 UTC] stingbat at stingbat dot dk
Ah I see, that's okay :)

Thanks for the fix anyway.

// over and out ;-)
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu May 06 01:01:24 2021 UTC