How To Add Slashes To Escape Strings

How can I use PHP to add slashes to escape strings

  • 1. use get_magic_quotes_gpc() to check if magic quotes feature was enabled.
  • 2. use addslashes() function to quote string with slashes
$string = "GJkd'gk'";
if ( get_magic_quotes_gpc() )
    $string = stripslashes($string );

$string = addslashes( $string );
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments