Re: Segmented Code/HTML VS. ECHO??
| From: | Jason G. | Date: | Mon, 19 Nov 2001 11:16:37 +0000 |
| Subject: | Re: Segmented Code/HTML VS. ECHO?? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-75104@lists.php.net to get a copy of this message | ||
We are not writing in perl...
Php offers a very handy feature, the ability to go in and out of html/php code by just using <? ?> and the ability to echo data by using <?= $var ?>
Seperate as much of your HTML from your PHP as possible. It will assist in readability, and
maintenance.
---------------------------------------------------
<?php
$color = "#FFCC00";
$name = "Yogi";
?>
<font color="<?= $color ?>">The bear is <?= $name ?>.</font>
---------------------------------------------------
-Jason Garber
IonZoft.com
At 05:36 PM 11/18/2001 -0800, you wrote:
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/ladenOn 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 -- 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