PHP escape sequences are interpolated into strings, enclosed by single/double quotations or heredoc syntax. As its name, it is for escaping characters from being parsed as it is, literally.
Escape sequences are started with escaping character backslash (\) and there are two types of escape sequences. The two types are distinguished based on character following the escape character backslash, that is based on whether it is an alphanumeric or special character.
For example, this code shows the difference between parsing escape sequences with alphanumeric and non-alpha numeric characters.
<?php echo "PHP Escape Sequences:\n Backslash \\ is used as an escaping character."; ?>
In the above PHP program, we have used two escape sequences \n and \\.
Among the above list of PHP escape sequences, only the first list item is applicable for single quoted string. All other escape sequences will work only with double quoted strings.
This PHP code tutorial was published on November 8, 2013.