Avoiding Duplicating Code

R

Robb

My header (images and a couple links), main menu, and footer are the same on all pages. Can they be
put into an external file instead of duplicated on every page?

Thanks,
Robb
 
P

password

Robb said:
My header (images and a couple links), main menu, and footer are the same on all pages. Can they be
put into an external file instead of duplicated on every page?
php and includes

make main content bit a php file
make your header menu etc a separate html file
make footer a separate html file

then at top and bottom of php page do

<?php
include('whereeveritis/header.html');
?>

php content stuff goes here
<?php
include('whereeveritis/footer.html');
?>

'whereveritis' is the route to the html files
you may have to fiddle with route to your css because the 'includes' think
(behave as if) they are where the php page is located even if they are in a
different folder

i hope that is clear
 
R

Robb

Thanks, I'll give this a try.


php and includes

make main content bit a php file
make your header menu etc a separate html file
make footer a separate html file

then at top and bottom of php page do

<?php
include('whereeveritis/header.html');
?>

php content stuff goes here
<?php
include('whereeveritis/footer.html');
?>

'whereveritis' is the route to the html files
you may have to fiddle with route to your css because the 'includes' think
(behave as if) they are where the php page is located even if they are in a
different folder

i hope that is clear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top