PDA

View Full Version : php Includes in websites


Glen
09-04-2007, 11:59 AM
When i first started my company site i never used php includes and used to have to change over 50 pages if i wanted to add a new site-wide link in my footer.

I then moved on to a couple, now on my new design I'm up to 5 php includes on every page. This basically just allows me to update all areas of the site (not the specific page content) just by updating 1 file.

Do people think there are any issues using a lot of includes or do you think its a good idea? And do you use them yourself?

P.S. Im talking about this:
<?php include("http://www.domain.com/includes/footer.php") ?>

Blazingpie
09-04-2007, 01:42 PM
includes are a life-saver, very handy. I use them all the time. only thing to remember is that if you implement a lot of them, especially if an include file has includes, you might end up with conflicts as the same include could be included twice or more.

Thus, require_once() is a brilliant way to prevent this. Its saved my butt tons of times :)

Glen
09-04-2007, 01:55 PM
awesome, just making sure it didn't slow down pages too much etc

I'm quite proud of myself as im no website designer ;)

Blazingpie
09-04-2007, 02:06 PM
awesome, just making sure it didn't slow down pages too much etc

the include command itself wont slow anything down. the code in the included file is another story, though...

Chatmaster
09-04-2007, 06:54 PM
I honestly cannot see you designing a site in any other way Glen. Includes are essential for any person to frequently update and mintain their sites.

alex
10-08-2007, 05:46 PM
every include opens a new file pointer in your os. But if your traffic is at the the level where this is an issue then you're running an accelerator anyway. Require once is a touch slower but usually worth it. Beats updating a world of files :-)