What are escaping characters? Explain with an example?
Page 1 of 1
What are escaping characters? Explain with an example?
Special characters are the characters that have some special meaning attached to it. Example is $, #, % etc. A backslash (\) before the special symbol is known as escaping characters. For example, two strings produce the same output:
$string = ‘The variable name is $var1’;
$string = “The variable name is \$var1”;
The output from either string is the following:
The variable name is $var1
Suppose you want to store a string as follows:
$string = _Where is Tom’_s house_;
echo $string;
The sting can be interpreted by PHP by putting a backslash (\) in front of the single quote. The backslash tells PHP that the single quote does not have any special meaning; it’s just an apostrophe. Example:
$string = _Where is Tom\’_s house_;
Similar topics
» What is SRF Files? Explain with an example.
» Explain the problem with COM.
» What is Stack? Explain its uses
» Explain abstraction.
» Explain one-definition rule (ODR).
» Explain the problem with COM.
» What is Stack? Explain its uses
» Explain abstraction.
» Explain one-definition rule (ODR).
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|