put slash on string code example
Example 1: add slashes to string
<?php
$str = "O'Reilly?";
eval("echo '" . addslashes($str) . "';");
?>
Example 2: add slashes to string
str = str.replace(/'/g, "\\'");
<?php
$str = "O'Reilly?";
eval("echo '" . addslashes($str) . "';");
?>
str = str.replace(/'/g, "\\'");