PHP is variable not working as expected -


i have php variable $username , following script:

<?php echo '<a href="#">'.$username.'</a>'; ?> 

if $username contains something <b bolds text. how can prevent that?

use htmlspecialchars

echo '<a href="#">'.htmlspecialchars($username).'</a>'; 

see documentation: http://php.net/manual/en/function.htmlspecialchars.php


Comments

Popular posts from this blog

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -