How to escape quotes in PHP?

by scotty_walker , in category: PHP General , 8 months ago

How to escape quotes in PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by darion , 7 months ago

@scotty_walker use addslashes() function to escape quotes in PHP, code:


1
2
3
4
5
6
<?php

$str = "How to 'escape quotes' in PHP?";

// Output: How to \'escape quotes\' in PHP?
echo addslashes($str);