PHP: predefined escape sequences

If a string is enclosed in double-quotes (“), PHP will interpret more escape sequences for special characters:

  • \n – linefeed (LF or 0x0A (10) in ASCII)
  • \r  – carriage return (CR or 0x0D (13) in ASCII)
  • \t – horizontal tab (HT or 0x09 (9) in ASCII)
  • \v – vertical tab (VT or 0x0B (11) in ASCII) (since PHP 5.2.5)
  • \f – form feed (FF or 0x0C (12) in ASCII) (since PHP 5.2.5)
  • \\ – backslash
  • \$ – dollar sign
  • \” – double-quote
  • \[0-7]{1,3} – the sequence of characters matching the regular expression is a character in octal notation
  • \x[0-9A-Fa-f]{1,2} – the sequence of characters matching the regular expression is a character in hexadecimal notation

Leave a Reply