Today came across a deal with a special character of the file, and again notice the problem in PHP:
* PHP strings with single quotes as delimiters, supporting two escape ' and \
* a PHP string with double quotes as delimiters that supports the following escapes:
N line-Wrapping (LF or ASCII character 0x0A (10))
R carriage return (CR or ASCII character 0x0D (13))
T horizontal tab (HT or ASCII character 0x09 (9))
\ Backslash
$ dollar Sign
"Double quotes
[0-7] {1,3} This regular expression sequence matches a character represented by a octal symbol
x[0-9a-fa-f]{1,2} This regular expression sequence matches a character represented in hexadecimal notation
Give a few examples:
An example that contains special characters:
$str = "FFFFFFFF";
Echo (strlen ($STR));
Echo ("n");
For ($i =0 $i <strlen ($STR); $i + +) echo ("T". Ord ($str {$i}));
Echo ("n");
Output results:
----------------------
9
102 102 102 102 0 102 102 102 102
Example of replacing special characters
$str = "FFFFFFFF";
$str = Str_replace ("x0", "", $str);
or use $STR = Str_replace ("", "", $str);
or with $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 results:
----------------------
8
102 102 102 102 102 102 102 102
Octal ASCII code example:
//Note that a string that conforms to the regular [0-7]{1,3} represents an octal ASCII code.
$str = "1237101188"; ///Here 8 does not meet the requirements, is amended to "\8 " (ASCII is 92 and a)
Echo strlen ($str ));
Echo ("n");
for ($i =0; $i <strlen ($STR); $i + +) echo ("T". Ord ($str {$i}