-2

Syntax error screenshot

I am getting this syntax error while using heredoc in php.

Unexpected: << after: =

Can somebody help me with this?

cn007b
  • 15,878
  • 6
  • 57
  • 69

1 Answers1

0

Problem not with <<<END_OF_BLOCK but with END_OF_BLOCK; you must not use whitespaces before END_OF_BLOCK;.

Here example:

<?php
$message = 'Hello World';
$variable = <<<EOT
    echo "{$message}";
EOT;
cn007b
  • 15,878
  • 6
  • 57
  • 69