|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-01-21 09:23 UTC] hkh at netnords dot dk
Description:
------------
When using (float)$dd for typecasting a string to a float, I get a wrong result back, because PHP convert . to ,
Later using the result outside PHP troubles begin.
Thinks it happens because we have used setLocale('da_DK'), because we i Denmark use , instead of .
Why just use . everytime, as in other programming-languages ?
Reproduce code:
---------------
print ((float)'1.5').'<br>'; // Result 1,5
print ((float)'1,5').'<br>'; // Result 1 - Fine with me
Expected result:
----------------
1.5
1
Actual result:
--------------
1,5
1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 15 14:00:01 2025 UTC |
BTW: Ubuntu 13.10 $ php -v PHP 5.5.3-1ubuntu2.2 (cli) (built: Feb 28 2014 20:06:05) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans