How to escape quotation marks in PHP?

Spread the love

Sometimes, we want to escape quotation marks in PHP.

In this article, we’ll look at how to escape quotation marks in PHP.

How to escape quotation marks in PHP?

To escape quotation marks in PHP, we call the addslashes function.

For instance, we write

$str = "Is your name O'Donnell?";

echo addslashes($str);

to call addslashes with $str to escape the single quote in the $str string.

Conclusion

To escape quotation marks in PHP, we call the addslashes function.

Leave a Reply

Your email address will not be published. Required fields are marked *