Syntax: string addslashes ( string $str ) Description: Returns a string with backslashes before characters that need to be escaped. These characters are single quote (‘), double quote (“), backslash (\) and NUL Note: Using addcslashes() function we will configure the escaped string.
Example 1
<?php $str="How're you"; echo 'Input String :'.$str; echo '<br/>'; echo 'Output String (addslashes($str)) :'.addslashes($str); echo '<br/>'; ?>
OUTPUT
Input String :How're you Output String (addslashes($str)) :How\'re you
Example 2
<?php $str='We won"t do this'; echo 'Input String :'.$str; echo '<br/>'; echo 'Output String (addslashes($str)) :'.addslashes($str); echo '<br/>'; ?>
OUTPUT
Input String :We won"t do this Output String (addslashes($str)) :We won\"t do this
Example 3
<?php $str='Break This Line\n'; echo 'Input String :'.$str; echo '<br/>'; echo 'Output String (addslashes($str)) :'.addslashes($str); echo '<br/>'; ?>
OUTPUT
Input String :Break This Line\n Output String (addslashes($str)) :Break This Line\\n