PHP addcslashes() Function


The addcslashes() function is used to returns a string with backslashes before the specified characters in a given string.

Syntax
addcslashes(string,characters)
Parameters
  • string - (Required) Specifies the string to be escaped.
  • characters - (Required) Specifies the characters or list of characters to be escaped.
Example
<?php
echo addcslashes("It's a beautiful day","e");
echo addcslashes("It's a beautiful day","a..z");
?>

Output

It's a b\eautiful day
I\t'\s \a \b\e\a\u\t\i\f\u\l \d\a\y

Prev Next