How to escape quotes in PHP?

Member

scotty_walker

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

How to escape quotes in PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by darion , 3 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);