note 115442 added to language.types.string
| From: | . | Date: | Wed, 23 Jul 2014 19:57:07 +0000 |
| Subject: | note 115442 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200044@lists.php.net to get a copy of this message | ||
Here's an observation of HEREDOC:
<?php
function foo() {
return <<<EOT
Hello World
EOT
}
?>
This will give you a fatal error:
Parse error: syntax error, unexpected '}' in foo.php on line 6
To fix this, add a semicolon. I encountered this issue after removing the semicolon because my
editor wasn't highlighting correctly.
In my case, this works without messing up my editor's highlighting:
<?php
function foo() {
return <<<EOT
Hello World
EOT
;
}
?>
HTH
----
Server IP: 72.52.91.14
Probable Submitter: 74.204.99.226
----
Manual Page -- http://php.net/manual/en/language.types.string.php
Edit -- https://master.php.net/note/edit/115442
Del: integrated -- https://master.php.net/note/delete/115442/integrated
Del: useless -- https://master.php.net/note/delete/115442/useless
Del: bad code -- https://master.php.net/note/delete/115442/bad+code
Del: spam -- https://master.php.net/note/delete/115442/spam
Del: non-english -- https://master.php.net/note/delete/115442/non-english
Del: in docs -- https://master.php.net/note/delete/115442/in+docs
Del: other reasons-- https://master.php.net/note/delete/115442
Reject -- https://master.php.net/note/reject/115442
Search -- https://master.php.net/manage/user-notes.php