Escape Sequences

Escape sequences are sequences of characters with a special meaning. Most of the time, the literal value of the character displayed is its meaning, while, sometimes, there are other hidden meaning.

An escape sequence is dedicated to a technology, and they are rare the same between two technologies, or even, between two engines dedicated to that technology.

Here are some examples of escape sequences.

PHP, in strings:
  • n (new line)

  • t (horizontal tabulation)

  • “ (double quote, inside a double quoted-string)

  • “ This is not an escape sequence : single quoted string do not recognize this

  • u{01f418} : a unicode codepoint, representing an elephpant

  • 200 : a character in octal notation

  • x69 : a character in hexadecimal notation

HTML :
  • ´ (a acute accent)

  • &quote; (double quote)

Escape sequences should not be confused with escape characters, though they are related : some escape sequences are introduced by an escape character. Others rely on a format.

<?php

// \1 is an escape sequence that represents the first capturing parenthsis.
// It is a special meaning for REGEX.
preg_match('/(.)\1/', $string);

// Displays AA
echo "A\101";

?>

Documentation

See also String literals (MySQL), Lexical Structure (PostgreSQL), INI file