Re: Segmented Code/HTML VS. ECHO??
| From: | Christopher William Wesley | Date: | Mon, 19 Nov 2001 01:36:15 +0000 |
| Subject: | Re: Segmented Code/HTML VS. ECHO?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-75060@lists.php.net to get a copy of this message | ||
I _hate_ echo'n out big batches of HTML, so I never do it. I prefer to
include HTML, or have a class or function write HTML. However, printing
in heredoc style is very handy ... more so than sliced bread.
For example:
<?php
$color = "#FFCC00";
$name = "Yogi";
print <<<EOF
<font color="${color}">The bear is ${name}.</font>
<!-- this can be as much plain HTML intermixed with PHP
variables as you like -->
EOF;
print( date() );
?>
PHP code, followed by plain HTML (I put in some PHP variables, but they
aren't necessary) (without a bunch of echo/print calls, or having to
escape quotes), followed by more PHP ... wash, rinse, repeat as much as
necessary ... you get the picture. It works out rather nicely.
$0.02
~Chris /"\
\ / September 11, 2001
X We Are All New Yorkers
/ \ rm -rf /bin/laden
On Sun, 18 Nov 2001, Brad Melendy wrote:
> Hello,
> Other than the fact that sometimes, you just can't get raw HTML to process
> properly by dropping out of PHP code, what are the pros and cons of using
> RAW HTML or just ECHOING everything in PHP? Thanks for any insights.
>
> ..Brad
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>