String Interpolation and Heredoc
Double quoted strings read variables inside. Use {} for expressions. Heredoc and nowdoc hold long text.
Example
$n = "Ada"; $arr = ["x" => 5];
echo "Hi $n, x={$arr['x']}\n";
echo 'No $n here', "\n";
echo <<<EOT
Name: $n
EOT;Result
Hi Ada, x=5 No $n here Name: Ada
Exercise
Which quotes read variables?
quotesQuiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.