Forum Moderators: coopster
I have a horizontal menu with 5 main options .. then a sub menu (also horizontal and just below the main options) with sub options .. for each main option. Basically, I have 5 different PHP include menu files.
One thing I decided to do is a "you are here". So at the top of each page I added a:
$dir = "<span class=here>Option 1</span>";
Then in the appropriate anchot text position I added:
if ( $dir == Bangkok ) { echo "<span class=here>Option 1</span>"; } else { echo "Option 1"; }
The <span> creates a different text color, size and background color.
Now I'm thinking of doing the same thing selectively to different suboptions .. but I'm wondering if the extra functions will slow the load time.
In other words, how much PHP in static pages is too much.
Just for grins try using microtime() [us2.php.net] at the starts and ends of some of your scripts to profile them - it'll probably make you chuckle and resolve to write bigger scripts!
If you're not touching the database (it seems you're not) it should be pretty fast. Like cameraman said, time your scripts. Based on my experience I'm willing to bet the PHP dynamic menus on static pages will have very, very little impact to the script processing time. If you gzip or compress your content it will get to the client even faster. Do you have compression enabled?
If you take it a step further and cache the files (the menus are fairly static as well I assume) then that would make a difference as well.
[edited by: Swanny007 at 6:28 am (utc) on Mar. 7, 2008]
If you're not touching the database (it seems you're not) it should be pretty fast. Like cameraman said, time your scripts. Based on my experience I'm willing to bet the PHP dynamic menus on static pages will have very, very little impact to the script processing time. If you gzip or compress your content it will get to the client even faster. Do you have compression enabled?
Right now everything runs pretty fast. I'm on a slow broadband connection in Thailand and my index page that has about a dozen smallish optimized images (60K?) loads in about 10 seconds .. in Opera with cache flushed. Server is a VPS in the US.
One page that queries a database and loads 30 records (descriptions and thumbnails) loads completely in about 12 seconds.
As I think I understand, the menu include is a process, then the 1st if statement (actually, 5 if statements .. one for each menu option) would be a subsequent process, then the 2nd level if statement (actually .. not sure, maybe 10 if statements) would be subsequent to the previous process.
If you take it a step further and cache the files (the menus are fairly static as well I assume) then that would make a difference as well.