I want to code like this but I am limited the Problem is I dont want to brint the If statement out of the heredoc what is the solution

echo<<<ENDSTRING
             <div>
                  if($i==2) 
                     $i is 2
              </div>
              <div class='ProDividerA'></div>
ENDSTRING;

thanks Pedram

Is it even possible without ending the identifier.

<?php
echo <<<HEREDOC
<div>
HEREDOC;
if($i==2) {
echo <<<HEREDOC
$i is 2
</div>
HEREDOC;
}

I think this is the only possible way. I hope I am wrong. :)
Cheers,
Naveen

Um I think You're right I did think the same ... I'll check it if any body has any Idea please let us know

i wouldn't use heredoc syntax in a situation like that. just use echo to output the html to page.

if $i changes you could do this:

<?php
echo <<<HTML
<div>\$i is $i</div>
HTML;
?>

i don't know if thats what you were looking for

maybe this?

<?php
$output=<<<HEREDOC
<div>
HEREDOC;
if($i==2) {
$output.=<<<HEREDOC
$i is 2
</div>
HEREDOC;
}
echo $output;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.