-2

Syntax error screenshot

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

Unexpected: << after: =

Can somebody help me with this?

cn007b
  • 16,596
  • 7
  • 59
  • 74

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
  • 16,596
  • 7
  • 59
  • 74