On a question of speed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
liderbug
Forum Newbie
Posts: 19
Joined: Tue Jul 23, 2002 2:18 pm

On a question of speed

Post by liderbug »

Question: Is a web page faster to do everything under PHP or only use PHP on a limited basis - 1 large all inclusive PHP script or 27 one liners?
I.E.
<? php
echo "<table><tr><td> ...
mysql_query ("select * from ...
echo "$data[0] ...
etc etc etc

OR

<table><tr><td>
<?php mysql_query("select * from ... echo "$data[0] ?>
</td></tr>
</table>

Just an Enquiring mind... :?: or :crazy:
Thanks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: On a question of speed

Post by Christopher »

99% of the time taken by that code is the query. The difference is not worth it. You should focus on implementing it in the cleanest, most maintainable way. Tune later if you actually have a performance problem.

You will get the most benefit in PHP from: optimizing your SQL queries, using an opcode cache like APC, tuning HTTP caching.
(#10850)
Post Reply