localeconv()之前,你必須使用 '的setlocale':
setlocale(LC_ALL, "en_US");
$locale_info = localeconv();
http://php.net/manual/it/function.localeconv.php
或者,也許,檢查這個代碼: http://php.net/manual/it/function.number-format.php
<?php
$var = number_format(2234,2);
$var = number_format($var,2);
echo $var;
# Expected Output: 2,234.00
# Actual Output: 2.00
?>
//To fix, remove the thousands separator by setting the decimal point and thousands separator parameters like so:
<?php
$var = number_format(2234,2,'.','');
$var = number_format($var,2,'.','');
echo $var;
# Expected Output: 2234.00
# Actual Output: 2234.00
?>
享受你的代碼!
編輯: 我在Windows系統中打印localconv()數組返回,它是無效的。 setloca
le(LC_ALL, "en_US");
$cwLocaleInfo = localeconv();
function print_locale_conv($locale_info) {
echo "<pre>\n";
echo "--------------------------------------------\n";
echo " Informazioni sulla configurazione monetaria locale: \n";
echo "--------------------------------------------\n\n";
echo "int_curr_symbol: {$locale_info["int_curr_symbol"]}\n";
echo "currency_symbol: {$locale_info["currency_symbol"]}\n";
echo "mon_decimal_point: {$locale_info["mon_decimal_point"]}\n";
echo "mon_thousands_sep: {$locale_info["mon_thousands_sep"]}\n";
echo "positive_sign: {$locale_info["positive_sign"]}\n";
echo "negative_sign: {$locale_info["negative_sign"]}\n";
echo "int_frac_digits: {$locale_info["int_frac_digits"]}\n";
echo "frac_digits: {$locale_info["frac_digits"]}\n";
echo "p_cs_precedes: {$locale_info["p_cs_precedes"]}\n";
echo "p_sep_by_space: {$locale_info["p_sep_by_space"]}\n";
echo "n_cs_precedes: {$locale_info["n_cs_precedes"]}\n";
echo "n_sep_by_space: {$locale_info["n_sep_by_space"]}\n";
echo "p_sign_posn: {$locale_info["p_sign_posn"]}\n";
echo "n_sign_posn: {$locale_info["n_sign_posn"]}\n";
echo "</pre>\n";
}
?>
所以我已閱讀本: http://php.net/manual/it/function.setlocale.php
,我必須改變參數localeconv():
$lang = "us_US";
$language = 'english';
$codeset = "UTF8"; // warning ! not UTF-8 with dash '-'
date_default_timezone_set('Europe/Rome');
setlocale(LC_ALL, array($lang.'.'.$codeset,$lang.'@euro',$lang,$language));
$cwLocaleInfo = localeconv();
print_locale_conv($cwLocaleInfo);
惠特這些作品!
在* nix系統嘗試使用此:
$lang = "us_US";
$language = 'english';
$codeset = "UTF8"; // warning ! not UTF-8 with dash '-'
putenv('LANG='.$lang.'.'.$codeset);
putenv('LANGUAGE='.$lang.'.'.$codeset);
你一定要檢查什麼在這兩個變量$ cwLocaleInfo [ 「mon_decimal_point」], $ cwLocaleInfo [ 「mon_thousands_sep」],以確保您擁有有效seperaters等 – KyleK 2014-10-04 04:50:38
我想你是指這個代碼?我不是用php的familiart,但我發現這個代碼具有相同的php頁面頭文件// LOCAL SETTINGS爲js貨幣格式 – Andy8333 2014-10-05 04:18:00
$ _ENV [「application.cw」] [「currencyPrecedes」] = false; \t \t $ _ENV [「application.cw」] [「currencySymbol」] =「」; \t \t $ _ENV [「application.cw」] [「currencyDecimal」] =「。」; \t \t $ _ENV [「application.cw」] [「currencyGroup」] =「,」; \t \t $ _ENV [「application.cw」] [「currencySpace」] =「」; – Andy8333 2014-10-05 04:20:44