Page 1 of 1

here.doc

Posted: Wed Nov 26, 2003 3:30 pm
by d3ad1ysp0rk
how do you echo it without putting it in a variable first?
ie i usually use:

Code: Select all

$myvar = <<<M
HTML STUFF
M;

echo $myvar;
but now i'd like to just use it to echo HTML w/o escaping the quotes (in my attributes)..
is it..

Code: Select all

echo <<<a
HTML STUFF
a;
?

thanks
-justin

Posted: Wed Nov 26, 2003 3:38 pm
by microthick
When I need to output lots of HTML, I just get out of php mode, then re-enter when I'm done.

ie.

Code: Select all

<?php

if ($var == $var2) &#123;
?>
   //all of my html
<?php
 &#125;

?>

Posted: Wed Nov 26, 2003 3:41 pm
by DuFF
Yes that second example seems to be correct:
http://shat.net/php/notes/heredoc.php

Posted: Wed Nov 26, 2003 10:08 pm
by McGruff
Personally I think embedding html in php scripts is doing it the wrong way round. Scripts should just define a bunch of output vars, then print them in an html template.

Business logic, then presentation, nice and separate...

Posted: Thu Nov 27, 2003 2:08 am
by Nay
Yeah, I'm addicted to heredoc but I'm starting to go into what McGruff said. Sometimes people just miss a " and get a parse error and come running to me <_<.

Well, if it's your own project, blah, do what you want :lol:. If you're working in a group where you know the rest are non-PHP-ers then you might want to save the hassle. For me, it's because I'm publishing my CMS to the public and I'm sure every single one of them want to edit the HTML templates. Mixing PHP in them is just not an option.

-Nay

Posted: Thu Nov 27, 2003 7:55 am
by dull1554
just try

Code: Select all

Print <<< END
//your code here, all html tags work.
END;