PHP addslashes function

Syntax of addslashes

string addslashes(string string)

Returns escaped characters in string that have special meaning in SQL database queries. Single quotes (”), double quotes (“”), backslashes (), and the NUL-byte (\0) are escaped. The stripslashes() function is the inverse for this function

Example of addslashes

<?php
$str = "O'Reilly?";
eval("echo '" . addslashes($str) . "';");
?>

Leave a Comment