To include characters that are not allowed in a string, use an escape character.
An escape character consists of a backslash \
followed by the character you wish to insert.
For example, a double quote inside a string enclosed by double quotes is considered an illegal character.
$x
|
To resolve this issue, use the escape character \"
.
$x
|
Other escape characters commonly used in PHP include:
Code |
Result |
\’ |
Single Quote |
\” |
Double Quote |
\$ |
PHP variables |
\n |
New Line |
\r |
Carriage Return |
\t |
Tab |
\f |
Form Feed |
\ooo |
Octal value |
\xhh |
Hex value |