PHP addslashes() Function


The addslashes() function returns a string with predefined characters preceded by a backslash. The predefined characters are: single quote (') double quotes (") backslash (\) null

Syntax
addslashes(string)
Parameters
  • string - (Required) Specifies the string to be escaped.
Example
<?php
$txt = addslashes("It's a beautiful day");
echo $txt;
?>

Output

It\'s a beautiful day.

Prev Next