Page 1 of 1

PHP Include Function - Formatting

Posted: Wed Oct 21, 2009 12:36 pm
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.

Re: PHP Include Function - Formatting

Posted: Wed Oct 21, 2009 12:58 pm
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.