Ameen Zami Ameen Zami - 4 months ago 8
PHP Question

Why is there an error in this PHP code?

Answer

The first line of heredoc string must have NO indentation... like this:

    function __construct()
      { 
       $a = some_code();
       $b = some_more_code();
       $x = <<<EOT

line1
line2
line3
line4

EOT;    

        $c = even_more_code();
        $b = still_more_code();
        ...
        ...
        ...

see more here: HEREDOC interfering with code indentation

Comments