You are here: Home Programming PHP How to user PHP addcslashes() Function

How to user PHP addcslashes() Function

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

Syntax

addcslashes(string,characters)

Parameter
string is a required. Specifies the string to check
characters is a required. Specifies the characters or range of characters to be affected by addcslashes()

 

Note: Be careful using addcslashes() on 0, r, n and t. In PHP, \0, \r, \n and \t are predefined escape sequences.

 

Problem

We will add backslashes to certain characters in a string: add php openinh tag and closing tag to following code,

 

$str = "Hello, my name is Khabza.";
 echo $str."<br \>";
 echo addcslashes($str,'m')."<br \>";
 echo addcslashes($str,'K')."<br \>";

 

Solution

Hello, my name iskhabza.
Hello, \my na\me is Kabza.
Hello, my name is \Kabza.


Clientele

 

SIGN UP RIGHT NOW FOR EMAIL UPDATES

Share this post


blog comments powered by Disqus

Print PDF

HTML Codes
opinions powered by SendLove.to

Our valuable member Khabza has been with us since Thursday, 08 July 2010.

Show Other Articles Of This Author

Back to top
SA Topsites :: Simphiwe - Find me on Bloggers.com

Copyright © Green IT Web - Blog by Khabza in Cape Town 2012

Template by Joomla 1.7 Templates & Szablony Joomla.