Forum Moderators: phranque

Message Too Old, No Replies

PHP Pages

         

GhostPig

10:01 am on Feb 12, 2006 (gmt 0)

10+ Year Member



'lo all,

Wasn't too sure where to post this, but here goes anyway:

I have a selection of PHP pages that all have the same top & bottom section (there's 7 pages or so) - is there a quicker way to update these than altering them in each page individually?

Something similar to using SHTML pages with HTML?

If I've not explained what I'm after clearly, please say so, and I'll try to expand on my question.

Many thanks

Little_G

12:31 pm on Feb 12, 2006 (gmt 0)

10+ Year Member



Hi,

The easiest way I can think of is to extract the top and bottom sections and put them in their respective files.
i.e. 'header.php' and 'footer.php'.
Then you can call them with 'require_once()' [uk2.php.net].
You'll have to go through and edit all of your pages but only once.

henry0

1:18 pm on Feb 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add a bit of organization by:
Creating a dir named "includes" and drop in that dir
all your files to be included.

GhostPig

2:14 pm on Feb 12, 2006 (gmt 0)

10+ Year Member



That sounds like a great idea - thanks for that!

Do you think I will run into any problems using this method alongside switchable CSS?

henry0

2:29 pm on Feb 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure how your CSS is organized
all my work is done in PHP, HTML and CSS
Even 100% PHP generated pages are governed by CSS
so you should not have a problem
ex:in a combo HTML/PHP page
<span class....>
<?
PHP script;
?>
</span>

<edit>
BTW your pages are required to be named with a PHP extension
or
you need to tell your server to parse them as PHP
We have quite some info on that topic in the PHP section
</edit>