【发布时间】:2013-11-06 22:27:42
【问题描述】:
我有以下似乎正在改变我的字符集的代码。
$html = "à";
echo $html; // result: à
$html = preg_replace("/\s/", "", $html);
echo $html; // result: ?
但是,当我使用 [\t\n\r\f\v] 而不是特殊字符 \s 作为我的模式时,它可以正常工作:
$html = "à";
echo $html; // result: à
$html = preg_replace("/[\t\n\r\f\v]/", "", $html);
echo $html; // result: à
这是为什么呢?
【问题讨论】:
-
两者都为我提供相同的输出。 ideone.com/Xo7RLR
-
你用的是什么版本的PHP?
-
@user4035 PHP 版本 5.3.24
标签: php regex encoding character-encoding special-characters