You are here: Re: Coding style... « All PHP « IT news, forums, messages
Re: Coding style...

Posted by Curtis on 10/13/01 11:36

gerg <noemail@noemail.com> wrote in message
news:L_KdnViu1KTc8SbeRVn-pw@comcast.com...
>
> > <?php
> > global $user;
> > if ($user->uid) {?> <li><a href="logout" title="">Log
> > Out</a></li>
> > <?php } else {?> <li><a href="user/login" title="">Log
> > In</a></li>
> > <?php }?>
> >
>
> I've heard that it's actually faster (processor wise) to
do it this way,
> then to have the PHP engine parse the html, and then have
the browser
> render it. If you do it the above way, PHP doesn't have
to parse it
> there for it's faster. Is this not the case?
>
> Greg

Another poster observed that, Greg.

But on a CMS, where PHP is already doing so much, one
wonders if the putative speed increase would be worth the
convolution of mixing code--I'm very skeptical. I'd
sacrifice a 10% speed decrease for greatly increased code
maintainability any day. Too, one has to wonder the overhead
of all those <?php ?> start-stops, some embedding a single
curly brace.

As it turns out, last night I refactored a Drupal theme, one
that originally used that start-stop commingling of HTML and
PHP. The original was sheer torture to read; there were few
blocks of straight HTML, as almost every other line had PHP
conditional statements, then HTML, then PHP again. Can of
worms.

I chose to make *everything* a PHP statement. The finished
code was half as long and twice as easy to understand.


--

Curtis

Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to philosophical
thought.

 

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

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