简体   繁体   English

PHP:htmlentities无法使用变量

[英]PHP: htmlentities not working with variable

I'm using htmlentities() to convert characters like Ç and ® to its character codes. 我正在使用htmlentities()将Ç和®之类的字符转换为其字符代码。 I'm getting the texts from the MYSQL database. 我正在从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>";
}

However $row[2] is returning an empty string when using htmlentities(). 但是,当使用htmlentities()时,$ row [2]返回一个空字符串。 Does anyone knows what's wrong? 有谁知道怎么了?

Thanks! 谢谢!

您为什么不废弃“ htmlentities”而只使用

htmlspecialchars();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM