Forum Moderators: coopster

Message Too Old, No Replies

problem with heredoc

heredoc causing PHP script to fail...

         

kfancy

1:07 am on Oct 10, 2006 (gmt 0)

10+ Year Member



I'm having some serious trouble trying to figure out what is causing a heredoc output to fail. I have narrowed it down to it being the culprit (if I remove the heredoc block from my code, the script runs fine). also, I'm quite familiar with using the heredoc syntax as I use it a lot, but I can't see a dang thing in here that could cause it to fail. in my codeblock, there's no trailing whitespace on either line (initiating <<< line or closing line).

Oh yeah, this is running on PHP 4.3.9, FYI.

here's the codeblock:

print <<<EOD
<div id="action_box"><b>CDN Usage Stats:</b>
<br>last report date:<br>{$cdn_last_report}
<br>{$stats_report_link}
<br><br><hr><b>CDN Billing:</b>
<br>last bill date: {$cdn_last_billing}
<br><a href="?a=usage.billing.check">Check usage billing</a>
<br><a href="?a=usage.billing.check&filter=breach">Show accounts over threshold</a>
<br><a href="?a=usage.billing">Bill outstanding usage</a>
<br><br><hr><b>Subscription Billing:</b>
<br>last bill date: {$subs_last_billing}
<br><a href="?a=subs.billing.check">Check subscription billing</a>
<br><a href="?a=subs.billing">Bill outstanding subscriptions</a>
<br><br><hr><a href="?">Home</a>
</div>
EOD;

and here's the error being thrown:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in */index.php on line 115

anyone have any ideas?

\\ kfancy

smells so good

1:19 am on Oct 10, 2006 (gmt 0)

10+ Year Member



Can you help identify which is line 115?

eelixduppy

1:32 am on Oct 10, 2006 (gmt 0)




It is very important to note that the line with the closing identifier contains no other characters, except possibly a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs after or before the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by your operating system. This is \r on Macintosh for example. Closing delimiter (possibly followed by a semicolon) must be followed by a newline too.

If this rule is broken and the closing identifier is not "clean" then it's not considered to be a closing identifier and PHP will continue looking for one.If in this case a proper closing identifier is not found then a parse error will result with the line number being at the end of the script.


[us2.php.net...]

Check this first!

Good luck :)

[added]
>>there's no trailing whitespace on either line (initiating <<< line or closing line)

oops..hehe
Your example works for me. Look at line 115 and also look at what comes before this. There's something missing here :/
[/added]