fork download
  1. <?php
  2.  
  3. echo "PHP version: ".phpversion()."\n\n";
  4.  
  5. echo "The following should work in all PHP versions:\n";
  6. echo "\\x can escape a single hex digit: TAB\x9TAB";
  7. echo "\n\n";
  8.  
  9. echo "Three UTF-8 bytes via \\x: \xE0\xBC\x82"; # U+0F02
  10. echo "\n";
  11. echo "Four UTF-8 bytes via \\x: \xF0\x9F\x91\xBE"; # U+1F47E
  12. echo "\n\n";
  13.  
  14.  
  15. echo "Octal notation is \\888 where '888' = 1 - 3 octal digits (values 0 - 7; range 0 - 377):";
  16. echo "\n";
  17. echo "\\11 and \\011: tab\11tabby\011tab";
  18. echo "\n";
  19. echo "\\7, \\07, and \\007: bell\7bell\07bell\007bell";
  20. echo "\n";
  21. echo "\\076 = \076 ; \\176 = \176 ; \\476 = \476 ; \\576 = \576";
  22. echo "\n";
  23. echo "UTF-8 bytes for U+0F02: \\340\\274\\202: \340\274\202";
  24. echo "\n";
  25. echo "UTF-8 bytes for U+1F47E: \\360\\237\\221\\276: \360\237\221\276";
  26. echo "\n";
  27. echo "UTF-8 bytes for U+1F47E: \\760\\637\\621\\676: \760\637\621\676";
  28. echo "\n";
  29. echo "\n\n";
  30.  
  31. echo "The following should work starting in PHP version 7.0.0:\n";
  32. echo "Code Point / UTF-32 via \\u{}: \u{0F02}";
  33. echo "\n";
  34. echo "Code Point / UTF-32 via \\u{}: \u{1F47E}";
  35. ?>
  36.  
  37.  
Success #stdin #stdout #stderr 0.02s 24336KB
stdin
Standard input is empty
stdout
PHP version: 7.3.5-1+ubuntu19.04.1+deb.sury.org+1

The following should work in all PHP versions:
\x can escape a single hex digit: TAB	TAB

Three UTF-8 bytes via \x: ༂
Four UTF-8 bytes via \x: 👾

Octal notation is \888 where '888' = 1 - 3 octal digits (values 0 - 7; range 0 - 377):
\11 and \011: tab	tabby	tab
\7, \07, and \007: bellbellbellbell
\076 = > ; \176 = ~ ; \476 = > ; \576 = ~
UTF-8 bytes for U+0F02: \340\274\202: ༂
UTF-8 bytes for U+1F47E: \360\237\221\276: 👾
UTF-8 bytes for U+1F47E: \760\637\621\676: 👾


The following should work starting in PHP version 7.0.0:
Code Point / UTF-32 via \u{}: ༂
Code Point / UTF-32 via \u{}: 👾
stderr
PHP Warning:  Octal escape sequence overflow \476 is greater than \377 in /home/o35aGH/prog.php on line 21
PHP Warning:  Octal escape sequence overflow \576 is greater than \377 in /home/o35aGH/prog.php on line 21
PHP Warning:  Octal escape sequence overflow \760 is greater than \377 in /home/o35aGH/prog.php on line 27
PHP Warning:  Octal escape sequence overflow \637 is greater than \377 in /home/o35aGH/prog.php on line 27
PHP Warning:  Octal escape sequence overflow \621 is greater than \377 in /home/o35aGH/prog.php on line 27
PHP Warning:  Octal escape sequence overflow \676 is greater than \377 in /home/o35aGH/prog.php on line 27