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
Post a Comment