You are here: Re: WHAT ARE THOSE DARN BRACES DOING IN THERE? « PHP Programming Language « IT news, forums, messages
Re: WHAT ARE THOSE DARN BRACES DOING IN THERE?

Posted by Thiamath on 05/17/07 21:11

On May 17, 9:17 pm, cybervigilante <cybervigila...@gmail.com> wrote:
> My PHP is rusty, but I'm trying to follow Joomla code and I keep
> seeing reverse braces inside php blocks that look to me like they'll
> break the interpreter. The code works. What am I missing here? Is this
> something new to php5 or some preproccessor or something?
>
> Stuff like this:
>
> <?php } else { ?>
>
> or this. where you see that left brace right before the ? I haven't
> done php in a while. Am I forgetting something obvious?
>
> <?php if(mosCountModules('right')) { ?>
> <div id="mcontent">
> <div class="padding">
> <?php if(mosCountModules('top')) { ?>
> <div id="newsflash"><div class="newsflash"><?
> php mosLoadModules ('top');?></div>
> </div><?php } ?>
> <?php mosMainBody(); ?>
> </div>
> </div>
> <?php } else { ?>

Sorry for my english...
That braces are part of "embeeded control structures".
The point is to embeed control structures into HTML code instead of
embeed HTML code inside PHP code.
Your example translated to pure PHP code:

<?php
if(mosCountModules('right')) {
echo "<div id=\"mcontent\">";
echo "<div class=\"padding\">";
if(mosCountModules('top')) {
echo "<div id=\"newsflash\">";
echo "<div class=\"newsflash\">;
mosLoadModules ('top');
echo "</div></div>";
}
mosMainBody();
echo "</div></div>";
}else{
.........
?>

Is intended to avoid abuse of the "echo" sentence, etc.

 

Navigation:

[Reply to this 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

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