Status
Not open for further replies.

Porsche_maniak

Active Member
283
2009
0
40
Hi there.
I was wondering if i have many <?php tags in a single page - does that slow down the processing ?

Like
<?php echo 1; ?>
<?php echo 2; ?>
Of course that's a silly example .. i am talking about much more complex stuff.

Thanks
 
7 comments
You can try it your self.
By this code:
PHP:
  <?php
$time_start = microtime(true);

// Your stuff here....


$time_end = microtime(true);
$time = $time_end - $time_start;

echo "Process took $time seconds\n";
?>
I dont think this will slow down.
But try and let us also know.
 
It would be interesting to know a definite answer.

I had a page with loads of php tags once and converted it to all php, and the page load was over 1 seconds quicker.
 
Yea that's was a good idea.
So i tested for 4 echo's - 1st test was with only 1 php tag. So in each refresh it was giving different results but average of 1.45 sec.

And 2nd test with 4 more php tags (for each echo) gave average result of 1.47 sec.
So i guess it is really close and no worry about using many php tags. Thanks

EDIT : But hey it has 0.02 delay ! LOL
 
on micro level it does matter. Every letter is one byte and use memory and process, but most people don't notice it. I even asked Chuck Norris and he didn't notice it. He had to slow time...
 
Excellent example of premature code optimization. Stuff like this doesn't matter at all. You code in a structured and clean way to avoid any speed issues and in the end if you are still experiencing slowness you identify the bottleneck and eliminate it ;-)

Sent from my super awesome Samsung Galaxy S II
 
using separate tags helps in one condition: you have static html contents withing the pages (eg global page layout and html tags) so you put them outside php tags because you don't need php to process them and they are sent directly. Obviously you would win a couple of milliseconds ;)
 
Status
Not open for further replies.
Back
Top