Strings In Depth17 / 18
Up next

Heredoc and nowdoc

<?php
declare(strict_types=1);
$name = "Ada";
// heredoc interpolates like a double-quoted string
$bio = <<<TEXT
Name: $name
Role: engineer
TEXT;
echo $bio, "\n";
// nowdoc is literal: no interpolation
$raw = <<<'TEXT'
$name stays literal
TEXT;
echo $raw, "\n";
What you're solving

multi-line strings, with and without interpolation