You are here: Re: echo all the time vs echo at the end - what is faster « PHP Programming Language « IT news, forums, messages
Re: echo all the time vs echo at the end - what is faster

Posted by Colin McKinnon on 11/04/05 23:08

windandwaves wrote:

> echo "<head> ";
> {code code code}
> echo "<body>";
> {code code code, talk to the database, etc...}
> echo "<div>some more shite</div>";
> {code code code}
> echo "</html>";
>
>
> Now I do this:
>
> $v .= "<head> ";
> {code code code}
> $v .= "<body>";
> {code code code, talk to the database, etc...}
> $v .= "<div>some more shite</div>";
> {code code code}
> $v .= "</html>";
> echo $v;
>
> The advantage of the second method is that I can still manipulate the
> content before it goes out. for example, I can replace double spaces and
> tabs, alter menus, etc... using simple replace functions.
>
> Now, my question is, what is faster or better? I kind of like the latter
> option, but I do not want to use it if it makes my website (significantly)
> slower.
>

I think you've answered your own question as to which is better. Regards the
question of speed - why don't you measure it. I suspect you'll find the
latter is faster because it won't use chunked encoding - particularly if
you are using compression.

A better way of buffering the output is to use PHP's output buffering
functions.

C.
> Cheers
>
>
> Nicolaas

 

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

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