简体   繁体   中英

PHP: htmlentities not working with variable

I'm using htmlentities() to convert characters like Ç and ® to its character codes. I'm getting the texts from the MYSQL database.

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(). Does anyone knows what's wrong?

Thanks!

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

htmlspecialchars();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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