I'm trying to convert a single quote into its relevant HTML code for database insertion, but it does not appear to be working. When I create the following script:
<?php
$str = "& and ' and \" and < and >";
echo htmlspecialchars($str);
?>
My browser returns the following:
& and ' and " and < and >
What am I doing wrong? I've read the PHP manual on htmlspecialchars() function and it says it applies to single quotes, but it doesn't seem to be working for me.