0

I build a site and now I have tho following problem. I made a file header.php and footer.php These contain the top and bottom of my template. I did this so when changes made at the template I wont have to change it to every individual page.

Now my question is... Every page has a image header like "home" "portfolio" "faq"... and I want the image to change on everypage. When the page is index.php then it shows home.png and when were at faq.php it shows faq.png.

This is basicly my code:

<?php include ("header.php") ?> (this file contains the header image)
Content here
<?php include ("footer.php") ?>

I hope I you guy's understand it. If not, let me know and i'll try to make a better discription.

Thanks in advance!

1 Answer 1

5

In each page (index.php, faq.php, etc.) set the name of the image you want to show before including the header file

<?php
$image = "faq.png";
include("header.php");
?>

and in header.php

<img src="<?php echo $image; ?>" alt="Header Image" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.