What are Escape sequence in PHP ?
Escape sequences is the combination of the escape character ‘\’ and a letter, are used to signify that the character after the escape character should be treated specially. if you wanted to have the string in which “or ‘ or $ should be printed then , you would need escape characters because you have double quotes inside double quotes.And if we do not want to interpolate our string then we have to use Escape sequences Here is a list of the 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 (not always supported )
- \t– Print a tab character.
- \r– Print a carriage return (not used very often).
- \$– Print the next character as a dollar.
- \\– Print the next character as a backslash, not an escape character.Now if you want to print address of a file then you can write it like
$MyFile = “c:\\new\\folder1\\hello.txt“;
echo $MyFile; ////output will be c:\new\folder1\hello.txt
Escape sequences are very important in display and handling data on server because there are various characters which are reserve in php and if we want it into report then have to use Escape sequences.