up vote -2 down vote favorite
share [g+] share [fb]

I am getting a string parse error when doing something like this:

$str = <<<EOT
EOT;

Any idea why that might ever happen?

link|improve this question

1  
Can you post the exact error? What you posted doesn't cause any error that I can tell. ideone.com/MbmGP – Jared Farrish May 28 '11 at 17:50
I get no errors: ideone.com/SwzMH – Thrustmaster May 28 '11 at 17:53
feedback

1 Answer

up vote 5 down vote accepted

The termination of a heredoc has to be the VERY FIRST thing on a line, there can be no whitespace or indentation. So if you're doing this:

function myfunc() {
  $str = <<<EOT;
  EOT;
}

Your code will fail. You have to do this:

function myfunc() {
  $str = <<<EOT;
EOT;
}
link|improve this answer
That's probably what the problem is. – Jared Farrish May 28 '11 at 17:53
Also yes, this is assuming that the simplified example differs from the actual code – onteria_ May 28 '11 at 17:54
Using the source from Edit, which uses tabs instead of spaces: ideone.com/jJ0Ey – Jared Farrish May 28 '11 at 17:55
Yes that solved it!! Nice! Heart StackOverflow! – Genadinik May 28 '11 at 18:07
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.