在php中将latin1字符串转换为utf8

时间:2012-10-17 16:36:14

标签: php

  

可能重复:
  Convert utf8-characters to iso-88591 and back in PHP

我有这个连接到我的MySQL BD的php文件,BD调用是latin1_swedish_ci

这是我的PHP代码:

<?php

$con = mysql_connect("localhost","root","");
if (!$con) {
    die('Could not connect: ' . mysql_error());
}

mysql_select_db("ttbfb", $con);

$result = mysql_query("SELECT * FROM news");

while($row = mysql_fetch_array($result)) {

    echo $row['name'];

}

mysql_close($con);
?>

如何在获得回音之前将$ row ['name']字符串转换为utf8?

1 个答案:

答案 0 :(得分:2)