php empty string htmlspecialchars() -
so, trying use htmlspecialchars() protect website unfortunately got stuck in code:
<?php function wrap_nome($firstname, $lastname) { $join = htmlspecialchars($firstname, ent_quotes) . ' ' . htmlspecialchars($lastname, ent_quotes); if (mb_strlen($join) > 32) { $text = substr($join,0,32); return $text . " ..."; } else { return $join; } } $nome = wrap_nome($firstname, $lastname); echo '<span style="color:#7f7f7f;font-family:arial;font-size:13px;"><b>' . $nome . '</b></span>'; ?> initially thought problem maybe fact string $nome had double , single quotes, removed them , found out htmlspecialchars($lastname, ent_quotes) continues echoed , htmlspecialchars($firstname, ent_quotes) continues give me empty string!
if this:
echo '<span style="color:#7f7f7f;font-family:arial;font-size:13px;"><b>' . htmlspecialchars($nome, ent_quotes) . '</b></span>'; ... wont output anything.
any ideas of causing ?
htmlspecialchars returns false if gets error, happens if $nome contains characters can't represented in specified character set. character set defaults iso8859-1 before php 5.4, utf-8 since then, try using htmlspecialchars($nome, ent_quotes, 'iso8859-1').
if doesn't work, see list of character sets in documentation , use appropriate 1 names.
Comments
Post a Comment