我努力在我正在开发的网站上获得正确的编码输出。但是当我使用mysql_set_charset
函数时,我在网站上得到了正确的编码。无法处理mysql_set_charset变量
但是奇怪的是 - 在使用这个函数之后 - 我无法正确处理变量。右我的意思是例如下面的代码无法正常工作(这它,当我不使用mysql_set_charset
功能):
$replace = array("å", "ä", "ö");
$with = array("a", "a", "o");
$test = str_replace($repalce, $with, $test);
$test = strtolower($test);
connect.php
$connection = mysql_connect("localhost", "****", "****") or die(mysql_error());
mysql_set_charset('utf8',$connection);
mysql_select_db("****", $connection) or die(mysql_error());
怎么会出现这种情况,我应该如何解决它?
是否已进行了确认您还可以使用正确的编码上的前端太了解了吗? – Repox
您在'$ test = str_replace($ repalce,$ with,$ test)行中输入了'$ repalce'而不是'$ replace'。 ' – Nasreddine
该死,尴尬。谢谢你敏锐的眼睛! – Fredrik