Enemy of the State Enemy of the State - 1 year ago 156
PHP Question

Heredoc not working


$information = <<<INFO
Name: John Smith
Address: 123 Main St
City: Springville, CA

echo $information;



Parse error: syntax error, unexpected T_SL on line 3

Answer Source

The parser is complaining because you have whitespace after the angled brackets declaring a heredoc. You need to make sure you're actually following the heredoc syntax, which you can find on the PHP Manual site (specifically: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc).

$information = <<<ENDHEREDOC
this is my text
echo $information;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download