i am trying to include a php header inside each of the pages i make. Now as far as i know, it can be done by using <?php include('header.php'); ?>inside each file.
Now my problem is that i have 5 pages, and in the header php i have a nav which links to each of this pages. When i load the header i would like to change the link of the file which the header is loaded on.
Ex: if i open the Home page, i want the header to have the link inside the header nav bolded.
That would probably require me to send a variable to the header file when i include it or smt? if so, than how to do that ? 😀
Thank you in advance, Daniel!
You can either do this by setting a variable before including the header or by looking at the URL.
A simplified example:
In
header.phpThe following code will give you the file name from the URL
So if you have
http://mysite.com/index.phpit’ll give youindex.phpYou can use this in your
header.phpsimilarly to how I described above to decide which link to bold.