我在php中打印货币符号有问题,当我使用echo函数打印货币符号时输出错误
我试试这段代码 我有像
这样的数组'Turkey New Lira - TRY' => 'も'
$key = $row['Currency']; $value = $array_currency[$key]; echo $value;
我有这个打印代码
$key = $row['Currency']; $value = $array_currency[$key]; echo $value;
我得到像
这样的输出一个,
另外有回声json_encode得到输出的问题,如
\u3082
给我正确的解决方案
答案 0 :(得分:0)
将元标记添加到您的html
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
对于json_encode
$string="も";
echo $string."<br/>";
echo "Encoding: " . mb_detect_encoding($string) . "<br/>";
$encoded = json_encode($string);
echo "Encoded val: $encoded <br/>";
$encoded2 = json_encode($string, JSON_UNESCAPED_UNICODE);
echo "Encoded val(with param): $encoded2 <br/>";
$decoded = json_decode($encoded);
echo "Decoded val: $decoded <br/>";
输出中
も
Encoding: UTF-8
Encoded val: "\u3082"
Encoded val(with param): "も"
Decoded val: も