[thelist] php curiosity

Richard Livsey R.Livsey at cache-22.co.uk
Tue Feb 20 11:39:09 CST 2001

> hey all...
> i'm just curious...  let's say that i have 3 php statements:
> 	<?php foo1 ?>
> 	<?php foo2 ?>
> 	<?php foo3 ?>
> is writing it that way more resource-intensive than writing them as:
> 	<?php
> 	foo1
> 	foo2
> 	foo3
> 	?>
> i know we're probably talking about miniscule differences... and
> yeah, i know it's kind of anal, but efficient code is a beautiful
> thing, no?  just curious...

Hi jason.

(Anyone feel free to correct me if Im wrong, this is just info I have picked
up from #php on IRC and places such as that over the years)

Yes, writing statements in seperate tags is less efficient than enclosing
them all together.
The server has to look for the opening and closing tags to decide what to
parse. The less tags, the less work the server does.
It is encouraged to put as much code inbetween the tags as possible, IE
cutting down on the number of tags per page. This is the reason that for a
lot of the work I do, I seperate the HTML and PHP as much as is possible,
often having the PHP in a seperate file and using a HTML file as a template
(FastTemplates are excellent btw!).

I havent got any info to hand on how much it affects the processing
time/load but Im sure someone here has some more info.

Freelance web developer
Vibus.net Director
Lead programmer for Tickle.co.uk
m. +44 (0) 7714 757250
e. R.Livsey at Cache-22.co.uk

More information about the thelist mailing list