Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-20-2012, 01:57 AM   PM User | #1
RonnyNishimoto
New Coder

 
Join Date: Jul 2012
Posts: 85
Thanks: 53
Thanked 0 Times in 0 Posts
RonnyNishimoto is an unknown quantity at this point
EOT Heredoc Parse Error

I get a funny error when the "EOT" or the "$end" is indented.

PHP Code:
<?php
echo <<< EOT
    HELLO!
EOT;
?>
which I researched to be exactly the same as:

PHP Code:
<?php
echo <<< PINEAPPLES
    HELLO!
PINEAPPLES;
?>
^ works. But if I indent the $end
PHP Code:
<?php
echo <<< PINEAPPLES
    HELLO!
    PINEAPPLES;
?>
it produces an error?:

Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_END_HEREDOC or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN

This seems really funny to me, does anyone know why it does this? I'm more curious as to learn why it gives me an error than "You just can't."
I indent all my code, so if I was territory that is indented 20 times, that would mean I would have to put the $end on the very first indent?

Last edited by RonnyNishimoto; 07-20-2012 at 05:17 AM..
RonnyNishimoto is offline   Reply With Quote
Old 07-20-2012, 02:40 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You cannot indent the ending delimiter (this is documented as such as well). You must put it on a line of its own, and it must not have any preceding whitespace.

So I'm afraid the answer is "You just can't". Its the way the parsing engine works on the heredoc and nowdoc syntax.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
RonnyNishimoto (07-20-2012)
Old 07-20-2012, 02:55 AM   PM User | #3
RonnyNishimoto
New Coder

 
Join Date: Jul 2012
Posts: 85
Thanks: 53
Thanked 0 Times in 0 Posts
RonnyNishimoto is an unknown quantity at this point
:O That really, really sucks. If that's the case, it's pretty much worthless. Thanks again Fou!

Last edited by RonnyNishimoto; 07-20-2012 at 02:58 AM..
RonnyNishimoto is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:10 AM.


Advertisement
Log in to turn off these ads.