Reputation: 6370
I have the code below:
<?php echo $fields->question; ?>
I specifically want to strip out any special characters that may cause an issue with php, how could I do that? Specifically "" is causing me a problem at the moment.
Upvotes: 0
Views: 278
Reputation: 12142
<?php echo htmlentities($fields->question, ENT_QUOTES, "UTF-8")?>
Upvotes: 2
Reputation: 5561
Have you tried the addslashes() native PHP function?
$foo = addslashes($fields->question);
echo $foo;
This won't strip them out, but it should prevent them from causing you any problems by escaping the quotes.
Upvotes: 1