Why does the error Parse error: syntax error, unexpected $ end result?

<?php $x=10; echo <<<МЕТКА $x МЕТКА; ?> <?php $x=10; echo <<<МЕТКА $x МЕТКА; ?> 

But if you copy all the php code above and replace it with the code below, the error disappears, why? visually nothing changes.

And I do not understand, where is the mistake here?

 <?php echo <<<RRR fff RRR; ?> 

    1 answer 1

    In the second case, you have a space after the label, which is prohibited by the HEREDOC rules! It is also not necessary; put after the mark

     <?php $x=10; echo <<<МЕТКА $x МЕТКА ?> <?php $x=10; echo <<<МЕТКА $x МЕТКА ?> 
    • In general, I recommend reading php.net/manual/ru/language.types.string.php#language.types.string.syntax.heredoc. And also think about the feasibility of using HEREDOC. As a rule, they use 'text' or 'text and /' escaped / 'characters and {$ variables} " - Dmitry
    • If it's not a secret, in which editor do you write the code? - Dmitriy
    • I write in notepad ++ - DivMan
    • @DivMan, try phpstorm, it gives a trial free version for 1 month, and then you can simply reinstall it. In any case, if you are planning to professionally develop you will need to use an IDE. A huge advantage of this is not only checking the syntax, but also the use of variables, etc. It saves a lot of time debugging children's errors. download jetbrains.com/phpstorm - Dmitriy