PHP Basic Tutorial
MySQL Connection
PHP Advanced
Escape characters are used to represent characters that are difficult or impossible to type directly in a string, or to insert special characters within a string. These escape characters are typically represented with a backslash (\
) followed by a character or a sequence.
Here’s a list of commonly used escape sequences in PHP:
Escape Sequence |
Description |
Example |
---|---|---|
\' |
To include single quotes inside a string |
|
\" |
To include double quotes inside a string |
|
\\ |
To include a literal backslash ( |
|
\n |
To insert newline characters ( |
|
\r |
Moves the cursor to the start of the line |
|
\t |
It inserts a horizontal tab space |
|
\f |
Form feed(Rarely used) |
"Text\fEnd" |
\xXX |
Hexadecimal character (XX is a two-digit hex number) |
|
\u{XXXX} |
Unicode escape (for characters above 255) |
echo "Hello \u{1F600}"; |