我正在尝试从mysql数据库中打印希伯来语(UTF8)中的简单字符串。在数据库中字符串是正确的,但是当我打印字符串时,它看起来像这样 - × - ×ות_× - יות。
如果你能帮助我理解为什么会这样,我会很高兴,我该如何解决它。感谢。
php -
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_set_charset($conn,"utf8");
$sql = "SELECT * FROM Items WHERE id = '$token'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "," . $row["title"];
}
} else {
echo "Not found row";
}
mysqli_close($conn);
答案 0 :(得分:0)
您的HTML文档如何?您是否将UTF8设置为字符集? 它应该是这样的:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<?php
//your php code
?>
</body>
</html>