PHP addcslashes() Function

The addcslashed() function in PHP is used to add quote string with slashes in a C style. It is case-sensitive function. 

Syntax

addcslashes (str, charlist )

Parameter

str(required)- This parameter represents the string to be escaped.

charlist(required)- This parameter signifies a character or range to be escaped.

Return 

This function returns a string with backslashes in front of the given characters.

Example 1

    

Output

Original String : TutorialAndExample
After adding slashes in the string: Tutorial\AndExample  

Example 2

    

Output

Original String : Tutorial and Example
After adding slashes in the string: Tutori\al \and Ex\ample  

Example 3

  

Output

 Actual String: Welcome to Tutorial And Example!
 \Welcome to \Tutorial \And \Example!
 W\e\l\c\o\m\e \t\o T\u\t\o\r\i\a\l A\n\d E\x\a\m\p\l\e!
 W\el\com\e to Tutori\al An\d Ex\ampl\e! 

Example 4

    

Output

Original String : Tutorial and Example!!!
After adding slashes in the string: Tutorial and Example!!!