0
我有以下腳本:使用的setlocale()不影響脈動熱管數量的轉換
<?php
$test = "2.5";
echo (float)$test;
echo "\n";
$r = setlocale(LC_ALL, "da_DK.UTF8");
setlocale(LC_ALL, NULL);
print_r(localeconv());
echo "\n";
echo (float)$test;
echo "\n";
echo (float)"2,5";
echo "\n";
?>
產生以下的輸出:
2.5
Array
(
[decimal_point] => ,
[thousands_sep] => .
[int_curr_symbol] => DKK
[currency_symbol] => kr
[mon_decimal_point] => ,
[mon_thousands_sep] => .
[positive_sign] =>
[negative_sign] => -
[int_frac_digits] => 2
[frac_digits] => 2
[p_cs_precedes] => 1
[p_sep_by_space] => 2
[n_cs_precedes] => 1
[n_sep_by_space] => 2
[p_sign_posn] => 4
[n_sign_posn] => 4
[grouping] => Array
(
[0] => 3
[1] => 3
)
[mon_grouping] => Array
(
[0] => 3
[1] => 3
)
)
2,5
2
的最後一行字2
- 我會預計讀2,5
- 就我所知,它應該在PHP文檔中看到。
如果省略第二次撥打電話setlocale
,則localeconv()
的輸出與丹麥語區域不一致 - 因爲我不清楚。
不幸typecasting _is_受setlocale影響: echo(setlocale(LC_ALL,array('de_DE','deu_deu'))); $ p = 3.1412592; var_dump($ p); var_dump((string)$ p); var_dump((float)(string)$ p); – andig 2014-03-24 12:30:32