[PHP] Interpolate a variable in a heredoc string

Created on November 30, 2026

Use {$name} inside a heredoc to insert the value of $name into the string.

<?php

$name = 'Taro';

$heredoc = <<< STRING
Hello, {$name}.
Good bye.
STRING;

echo $heredoc;
Hello, Taro.
Good bye.
PHP