Heredoc Syntax In An Array
It was only possible to use the HEREDOC, and NOWDOC, syntax with a final semicolon. This meant it was impossible to use that syntax in an array, a list of arguments, or other context that do not finish the expression with a semicolon.
Since PHP 7.3, it is possible to use these syntaxes in more varied situations, such as method call, for example.
PHP code
<?php
$a = array(<<<HEREDOC
A
HEREDOC,
);
print_r($a);
?>
Before
PHP Parse error: syntax error
Parse error: syntax error
After
Array
(
[0] => A
)
PHP version change
This behavior changed in 7.3.