String Literals

String Literals, Heredoc and Nowdoc

Single quotes are literal: only \' and \\ are escapes. Double quotes expand variables and understand \n, \t, \$, \", hex \x41 and Unicode \u{20AC}. A heredoc (<<<ID) is a double-quoted string over several lines, and a nowdoc (<<<'ID') a single-quoted one. Since PHP 7.3 the closing identifier may be indented, that indentation is stripped from every line, and it may be followed by , or ).

Quotes, escapes, an indented heredoc and a nowdoc (literals.php)PHP
<?php
$name = 'Ada';
echo 'Single: $name\n it\'s literal', "\n", "Double: $name\t\x41 \u{20AC}5 \$5\n";
$shipped = fn(string $to, int $n): string => <<<TEXT
    Dear $to,
      your $n books have shipped.
    TEXT;
echo $shipped($name, 3), "\n", <<<'RAW'
    Nowdoc keeps $name and \n as typed.
    RAW, "\n";
Output
Single: $name\n it's literal
Double: Ada   A €5 $5
Dear Ada,
  your 3 books have shipped.
Nowdoc keeps $name and \n as typed.

The closing TEXT; sits four spaces in, so four come off each line and the extra two before "your" survive. A body line indented less than the closing identifier, or indentation mixing tabs and spaces, is a parse error. Nowdoc suits text full of $ signs, and a heredoc has no trailing newline.