|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31366 Weird bug with setlocale and serialize
Submitted: 2004-12-31 11:41 UTC Modified: 2005-02-02 00:11 UTC
From: info at smartlogic dot nl Assigned: derick (profile)
Status: Closed Package: Math related
PHP Version: 4CVS, 5CVS (2005-01-01) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
50 - 44 = ?
Subscribe to this entry?

 [2004-12-31 11:41 UTC] info at smartlogic dot nl
After setting the setlocale the decimal point disappears.

This is the same bug as "Bug #14235: serialize and setlocale: inconsistent behavior" but it still appears in PHP 4.3.10 while the possible solution indicates:

"This bug has already been fixed in the latest released version of
PHP, which you can download at

this was fixed in 4.1.x with the switch to a non-sprintf-based serialize implementation."

Reproduce code:
#code without setlocale
echo "* WITHOUT setlocale\n\n";

#code with setlocale
echo "* WITH setlocale\n\n";
setlocale (LC_ALL, 'nl_NL');

function bug_test()


         echo "Original Input: ".$bill_lines[0]["price"]."\n\nArray:\n\n";


         echo "\n\nSerialized array: $encoded \n\n";

         echo "Ouput after unserialize: ".$decoded[0]["price"]."\n\n";

Expected result:
The output after the setlocale and the unserialize is 42 instead of 42,02 or 42.02

Actual result:
* WITHOUT setlocal

Original Input: 42.02


    [0] => Array
            [price] => 42.02


Serialized array: a:1:{i:0;a:1:{s:5:"price";d:42.02000000000000312638803734444081783294677734375;}} 

Ouput after unserialize: 42.02

* WITH setlocale

Original Input: 42,02


    [0] => Array
            [price] => 42,02


Serialized array: a:1:{i:0;a:1:{s:5:"price";d:42.02000000000000312638803734444081783294677734375;}} 

Ouput after unserialize: 42


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-02 00:11 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 08:01:29 2023 UTC