php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #38785 float to string cast is always subject to locale settings
Submitted: 2006-09-11 23:35 UTC Modified: 2006-12-03 10:33 UTC
From: m dot kurzyna at crystalpoint dot pl Assigned: bjori (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.1.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: m dot kurzyna at crystalpoint dot pl
New email:
PHP Version: OS:

 

 [2006-09-11 23:35 UTC] m dot kurzyna at crystalpoint dot pl
Description:
------------
Stripslashes seems to be locale specific. It changes 
decimal point character when used in enviroment with 
locales set.

I'm not shure is this a feature or a bug but it's 
something unexpected as it's not mensioned in the manual 
as far as I know. And it's easy to criple database input 
with this.

As a locale to observe this behaviour one can set probably 
enything that uses comma rather then dot for decimal 
point.

Reproduce code:
---------------
$float = 0.10;   // $float is now float 0.10

setlocale(LC_ALL,'C');
$r = stripslashes($float);     // $r is now string "0.10"

setlocale(LC_ALL,'pl_PL');
$r = stripslashes($float);     // $r is now string "0,10"


Expected result:
----------------
No change in decimalpoint or explicit note in 
documentation.

Actual result:
--------------
Provided in code example - change of decimal point 
character.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-12 00:04 UTC] m dot kurzyna at crystalpoint dot pl
This behaviour is more general - it applyes to any float 
to string conversion wether it's explicit or implicit. 
There are some bugreports on this already though all are 
bound to some concrete functions.
 [2006-09-12 00:05 UTC] m dot kurzyna at crystalpoint dot pl
Wrong version in prevous comment.
 [2006-09-12 08:40 UTC] tony2001@php.net
Reclassified as docu problem.
 [2006-12-03 10:33 UTC] bjori@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Added a note from strtod(3) to 
php.net/language.types.string
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 01:01:31 2024 UTC