Backslash (\) is used in PHP as escaping character. Escape sequences are started with escaping character backslash (\).
List of widely used escape sequences in PHP:
\"
|
Print the next character as a double quote
|
\'
|
Print the next character as a single quote
|
\n
|
Print a new line character
|
\t
|
Print a tab character
|
\r
|
Print a carriage return
|
\$
|
Print the next character as a dollar
|
|
|
Here is a code example of these escape sequences in action:
<?php
echo "This is an \"escaped double quote\" string";
echo "Naman\'s photo";
echo "I have \$100 in my pocket";
echo "This ends with a line return\n";
echo "c:\\Download\\myfile.txt";
?>
echo "This is an \"escaped double quote\" string";
echo "Naman\'s photo";
echo "I have \$100 in my pocket";
echo "This ends with a line return\n";
echo "c:\\Download\\myfile.txt";
?>
Output :
This is an "escaped double quote" string;
Naman's photo
I have $100 in my pocket
This ends with a line return
c:\Download\myfile.txt
No comments:
Post a Comment