note 79559 deleted from function.setlocale by betz
| From: | betz@php.net | Date: | Tue, 04 Dec 2007 15:00:29 +0000 |
| Subject: | note 79559 deleted from function.setlocale by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-132800@lists.php.net to get a copy of this message | ||
Note Submitter: weboide [-@t-] yahoo [-d0t-] fr
----
Be careful when TYPECASTING using DIFFERENT LOCALES :
<?php
# WITHOUT LOCALE OR US_EN LOCALE :
var_dump((float)(string)9.2); # returns : float(9.2) (AS EXPECTED)
# WITH LOCALES USING a COMMA for floating part separator :
setlocale(LC_ALL, 'fr_FR');
var_dump((float)(string)9.2); # returns : float(9) (NOT EXPECTED AT ALL !!! CAREFUL!!)
?>
Any solution to this problem is welcomed.