PHP Include Function - Formatting

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
sgately
Forum Newbie
Posts: 3
Joined: Wed Oct 21, 2009 12:35 pm

PHP Include Function - Formatting

Post by sgately »

HI Guys,

I am new at PHP and figured this is the best place to get a quick answer, which I am sure is obvious to you.

I am having a problem integrating PHP templates into an existing HTML / PHP template. I see that there are tons of free scripts but it is a hair pulling experience to try an include any (scripts) into my existing webpage.

I have no problem installing the scripts, but when I try to add the template code into my website it expands the page and screws up the CSS look and feel.

My question is, do you recommend saving a PHP template and using the include function to maintain the look and feel of a page?

For instance inserting the Sphider search engine template into an existing page screws up the size, but will adding a PHP include function that points to the template from fix this?

Thanks for any help you can offer.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: PHP Include Function - Formatting

Post by superdezign »

The include directive essentially inserts the code from the included file into the current file, and executes it as though it was a part of the current file. There are subtle differences, such as the value of the global __FILE__ variable. But, it is essentially just like copying and pasting.

Some people use the include directive for templating, but that's generally only for the convenience of not having to copy code.
Post Reply