Notes for php character escape
- $ 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 II. 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 3. 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 4. 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 |