note 86365 added to language.types.string
| From: | SalilKothadia at osu1 dot php dot net | Date: | Wed, 15 Oct 2008 08:33:06 +0000 |
| Subject: | note 86365 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145370@lists.php.net to get a copy of this message | ||
An interesting finding about Heredoc "syntax error, unexpected $end".
I got this error because I did not use the php close tag "?>" and I had no code after
the heredoc code.
foo1.php code gives "syntax error, unexpected $end".
But in foo2.php and foo3.php, when you add a php close tag or when you have some more code after
heredoc it works fine.
Example Code:
foo1.php
1. <?php
2. $str = <<<EOD
3. Example of string
4. spanning multiple lines
5. using heredoc syntax.
6. EOD;
7.
foo2.php
1. <?php
2. $str = <<<EOD
3. Example of string
4. spanning multiple lines
5. using heredoc syntax.
6. EOD;
7.
8. echo $str;
9.
foo3.php
1. <?php
2. $str = <<<EOD
3. Example of string
4. spanning multiple lines
5. using heredoc syntax.
6. EOD;
7. ?>
----
Server IP: 69.147.83.197
Probable Submitter: 59.99.98.147
----
Manual Page -- http://www.php.net/manual/en/language.types.string.php
Edit -- https://master.php.net/note/edit/86365
Del: integrated -- https://master.php.net/note/delete/86365/integrated
Del: useless -- https://master.php.net/note/delete/86365/useless
Del: bad code -- https://master.php.net/note/delete/86365/bad+code
Del: spam -- https://master.php.net/note/delete/86365/spam
Del: non-english -- https://master.php.net/note/delete/86365/non-english
Del: in docs -- https://master.php.net/note/delete/86365/in+docs
Del: other reasons-- https://master.php.net/note/delete/86365
Reject -- https://master.php.net/note/reject/86365
Search -- https://master.php.net/manage/user-notes.php