Variables in strings

$a = 0.23;
$string = "{$a} is a float";

Access and alter characters of string

$string = "Hello World!";
 
echo $string[2]; // "l"
echo $string[-1]; // "!"
 
$string[0] = 'X';
echo $string; // "Xello World!"

HEREDOC and NOWDOC

Both don’t escape characters

// HEREDOC (reads variables)
$text = <<<TEXT
Line 1
Line 2 $a
Line 3
TEXT;
 
// NOWDOC (does not read variables)
$text = <<<'TEXT'
Line 1...
TEXT;