Php character escape considerations. In php: * a php string with single quotes as the delimiters. it supports two escape characters and a php string with \ * double quotes as the delimiters. the following escape characters are supported: n line breaks (LF or ASCII characters
In php:
* A php string with single quotes as the separator. two escape characters \ 'and \ are supported \\
* A php string with double quotation marks as the delimiter. the following escape characters are supported:
\ N line feed (LF or ASCII character 0x0A (10 ))
\ R press enter (CR or ASCII character 0x0D (13 ))
\ T horizontal tab (HT or ASCII character 0x09 (9 ))
\ Backslash
\ $ Dollar Sign
\ "Double quotation marks
\ [0-7] {} the regular expression sequence matches a character represented by the octal symbol
\ X [0-9A-Fa-f] {} this regular expression matches a sequence of characters represented by a Hexadecimal Symbol
For example:
An example with special characters \ 0:
$ Str = "ffff \ 0 ffff ";
Echo (strlen ($ str ));
Echo ("\ n ");
For ($ I = 0; $ I Echo ("\ n ");
Output result:
----------------------
9
102 102 102 102 0 102 102 102
Example of replacing special characters
$ Str = "ffff \ 0 ffff ";
$ Str = str_replace ("\ x0", "", $ str );
// Or use $ str = str_replace ("\ 0", "", $ str );
// Or use $ str = str_replace (chr (0), "", $ str );
Echo (strlen ($ str ));
Echo ("\ n ");
For ($ I = 0; $ I Echo ("\ n ");
Output result:
----------------------
8
102 102 102 102 102 102 102
Octal ascii code example:
// Note that the string that matches the regular \ [0-7] {} represents an octal ascii code.
$ Str = "\ 0 \ 01 \ 02 \ 3 \ 7 \ 10 \ 011 \ 08 \ 8"; // The \ 8 here does not meet the requirements, corrected to "\ 8" (ascii: 92 and 56)
Echo (strlen ($ str ));
Echo ("\ n ");
For ($ I = 0; $ I Echo ("\ n ");
Output result:
----------------------
11
0 1 2 3 7 8 9 0 56 92 56
Hexadecimal ascii code example:
$ Str = "\ x0 \ x1 \ x2 \ x3 \ x7 \ x8 \ x9 \ x10 \ x11 \ xff ";
Echo (strlen ($ str ));
Echo ("\ n ");
For ($ I = 0; $ I Echo ("\ n ");
Output result:
----------------------
10
0 1 2 3 7 8 9 16 17 255
A php string that uses single quotes as the separator. two escape characters \ 'and \ * are supported. the following escape characters are supported: \ n line feed (LF or ASCII characters...