PHP Programing language

addslash() Function in PHP
Previous Home Next
adplus-dvertising

addcslash()

The addcslashes() function returns a string with backslashes in front of the specified characters.

Syntax :
addcslashes(string,characters)

In syntax, "string" Specifies the string to be escaped and "characters" Specifies the characters or range of characters to be escaped.

Example:

<?php 
$str = addcslashes("Gud Morning...!!","M");
echo($str); 
?>

Output:

Gud \Morning...!!

addslash()

The addslashes() function returns a string with backslashes in front of predefined characters like: Single quotes (' '), Double quotes (" "), Backslash (\) and NULL.

Syntax:
addslashes(string)

In syntax, "string" Specifies the string to be escaped.

Example:

<?php 
$str = addslashes('Who are "you"?');
echo($str); 
?>

Output:

\"you\"

Previous Home Next