I was wondering whether:
$foo = <<< EOT
Hello, World!
EOT;
is just as valid as
$foo = <<<EOT
Hello, World!
EOT;
and in particular whether this is true in all versions of PHP (or just the latest ones).
I wonder because I want to know whether a space between the <<< and first EOT identifier is syntactically valid. For instance, my PHP interpreter 5.3.10 runs this correctly but
my vim text editor does not syntax-highlight the heredoc in the same way if there is a
space between <<< and EOT (the EOT identifier is colored white instead of purple).
So what is the deal here? Are both legal in all versions of PHP or not?
No, you should not provide a space between the <<< and the identifier. As specified in the PHP documentation:
Source: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc