Reply to Re: WHAT ARE THOSE DARN BRACES DOING IN THERE?

Your name:

Reply:


Posted by Good Man on 05/17/07 21:08

cybervigilante <cybervigilante@gmail.com> wrote in
news:1179435524.505510.163270@k79g2000hse.googlegroups.com:


> thanks. I had a feeling it was some trick I didn't normally see, or
> that I'd forgotten. Still a tad unclear. Why do they have the ?> right
> at the beginning of the code block, after the }, when they could just
> have a code block? Or do you mean when the HTML is done it literally
> steps back to that position, right before the ending ?> like a return
> statement. Or is the ?> there just to keep the interpreter happy?
> I'm just unfamiliar with this construction. It isnt' in any of the php
> primers that were gathering dust on my shelf ;')

This may help clear things up for you... both examples perform EXACTLY
the same (untested!)

Example 1:

<?php
if($butter=="yellow") {
echo "<h1>The butter is yellow!</h1>";
}
else {
echo "<h1>The butter is not yellow!</h1>";
}
?>


Example 2:

<?php
if($butter=="yellow") {?>
<h1>The butter is yellow!</h1>
<?php } else { ?>
<h2>The butter is not yellow!</h2>
<?php } ?>


Example 1 uses PHP to spit out the HTML; Example 2 goes in and out of
PHP so that the coder can just type straight HTML without having PHP do
it.

There are times when example 2 is preferred (huge blocks of HTML code)
but in general example 1 is the way to go I think....

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация