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 <strlen ($ Str); $ I ++) echo ("\ t". ord ($ STR {$ 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 <strlen ($ Str); $ I ++) echo ("\ t". ord ($ STR {$ 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 <strlen ($ Str); $ I ++) echo ("\ t". ord ($ STR {$ 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