我正在使用 htmlentities() 将 Ç 和 ® 等字符转换为其字符代码。我正在从 MYSQL 数据库中获取文本。
while($row = mysql_fetch_array($array, MYSQL_NUM)){
echo "<div style='float:left; margin-right:40px;'>
<div style='width:148px; height:141px; background-image:url(uploads/".$row[0].")'>
<img src='images/glasscase.png' alt=''/>
</div>
<font style='font-size:20px'>".htmlentities($row[1], ENT_QUOTES,"UTF-8")."</font>
<br/>
<font style='font-size:14px'>".htmlentities($row[2], ENT_QUOTES, "UTF-8")."</font>
</div>";
}
但是 $row[2] 在使用 htmlentities() 时返回一个空字符串。有谁知道出了什么问题吗?
谢谢!
最佳答案
你为什么不废弃'htmlentities'而直接使用
htmlspecialchars();
关于PHP:htmlentities 不使用变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3882867/