kdsxchris Posted June 8, 2007 Share Posted June 8, 2007 <?php $bar = <<<EOT bar EOT; ?> I get the error "Parse error: syntax error, unexpected $end in FILE on line 4" I've done this a thousand times and I'm about to die. What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/54697-what-the-hell-heredoc-style-string/ Share on other sites More sharing options...
DJTim666 Posted June 8, 2007 Share Posted June 8, 2007 What the hell, does that code do? Shouldn't you be echo'ing the EOT thing? Quote Link to comment https://forums.phpfreaks.com/topic/54697-what-the-hell-heredoc-style-string/#findComment-270499 Share on other sites More sharing options...
kdsxchris Posted June 8, 2007 Author Share Posted June 8, 2007 It's saving a string to a variable...http://us2.php.net/types.string I wrote my own code that gave a similar error, so to be sure I wasn't insane I copied and pasted code from the php doc website and even that didn't work. I know I'm writing in correct syntax, but the parser says otherwise... Quote Link to comment https://forums.phpfreaks.com/topic/54697-what-the-hell-heredoc-style-string/#findComment-270501 Share on other sites More sharing options...
btherl Posted June 8, 2007 Share Posted June 8, 2007 Make sure you have no stray whitespace after the EOT (such as a tab). Heredoc syntax is quite fragile. Your syntax *looks* fine, which means there's something you can't see that is causing the problem. You might want to recreate the file from scratch if nothing else works. Quote Link to comment https://forums.phpfreaks.com/topic/54697-what-the-hell-heredoc-style-string/#findComment-270510 Share on other sites More sharing options...
kdsxchris Posted June 8, 2007 Author Share Posted June 8, 2007 I checked for whitespace and all of that...I'm really stumped on what to do. I'll just it the old fashioned way now... Quote Link to comment https://forums.phpfreaks.com/topic/54697-what-the-hell-heredoc-style-string/#findComment-270518 Share on other sites More sharing options...
btherl Posted June 8, 2007 Share Posted June 8, 2007 I copied and pasted your script and it works fine here.. If you copy and paste it from the website here does it work for you? Quote Link to comment https://forums.phpfreaks.com/topic/54697-what-the-hell-heredoc-style-string/#findComment-270525 Share on other sites More sharing options...
btherl Posted June 8, 2007 Share Posted June 8, 2007 Oh, one more idea.. if that code is part of a larger script, keep in mind that the error may be elsewhere, not in the code you are staring at.. that's gotten me a few times Quote Link to comment https://forums.phpfreaks.com/topic/54697-what-the-hell-heredoc-style-string/#findComment-270527 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.