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

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -