I've recently come upon a very intriguing issue. I have the following code on a website to generate a number composed by 10 digits, followed by a period (.), followed by 2 to 4 digits. I also use the gettext function to translate the page into 2 other different languages
<?php
$lang = "en_UK";
putenv("LC_ALL=$lang");
setlocale(LC_ALL, $lang);
bindtextdomain("messages", "locale");
bind_textdomain_codeset('messages', 'UTF-8');
textdomain("messages");
list($usec, $sec) = explode(" ",microtime());
$my_number = ((float)$usec + (float)$sec + (float)rand(1, 100000000));
?>
<form method ="POST" action="">
<input type="hidden" value="<?php echo $my_number; ?>"/>
<input type="submit"/>
</form>
So far so good. When $lang
is equal to en_UK, I get what I need (1234567891.1234).
But if $lang
is equal to it_IT, or de_DE, then $my_number
changes format to 10 digits, followed by a COMMA, followed by 2 to 4 digits (1234567891,1234).
Does anybody now why this happens??? Thanks a lot :)
Different countries have different conventions about how to write numerals. setlocale
changes the conventions your program uses.