开发者

Strip out special characters in php

开发者 https://www.devze.com 2023-04-02 03:54 出处:网络
I have the code below: <?php echo $fields->question; ?> I specifically want to st开发者_如何转开发rip out any special characters that may cause an issue with php, how could I do that? Spec

I have the code below:

<?php echo $fields->question; ?>

I specifically want to st开发者_如何转开发rip 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.


<?php echo htmlentities($fields->question, ENT_QUOTES, "UTF-8")?>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号