Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

heredoc back and forth

Status
Not open for further replies.

webdev007

Programmer
Sep 9, 2005
168
This is within a PHP page

// some php then

echo <<<CONTENT
any HTML
the following line ends the html section
CONTENT;

// back in php, I try to make the following php snippet working
// but it throws an error where I restart a new heredoc and the php snippet is not parsed
// instead the snippet is "printed"

if($secure_email=="y")
{
include"secure_email/";
}
else
{
echo"<span id=\"content\">$email</span></td></tr>";
}

// new heredoc to add more html is then throwing an error, error is the next line:
echo <<<END

How should I write it, I looked at the manual, tried " . ", tried {} but none works
 
i'm not sure why that include statement should work.

you might also consider putting spaces after your function and language construct calls.

one often missed issue is that the end of a heredoc must not contain any spaces or other stuff (other than linebreak) after the semicolon.
 
Well, even if I remove the new heredoc "start and stop"
and simply keep the php snippet within the heredoc
I still cannot parse it, it keeps "printing the snippet"
actally it could be any php snippet

so the real question should be
How to make a php snippet correctly working within a heredoc?
thanks for your answer
 
oh. i see. you're trying to include php within php. that does not work. there is no difference between heredoc and double quotes in this context.

to incorporate a conditional, break out of the heredoc, perform your conditional etc.


 
Thanks,
I was not trying to include php within php, my bad!, I just used whatever came to my mind to illustrate my problem, the real thing calls for a long URI...

yes simply breaking out did it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top