Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8420709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:56:10+00:00 2026-06-10T02:56:10+00:00

i am trying to include a php header inside each of the pages i

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:56:11+00:00Added an answer on June 10, 2026 at 2:56 am

    You can either do this by setting a variable before including the header or by looking at the URL.

    A simplified example:

    $page = "home";
    include "header.php"
    

    In header.php

    if ($page == "home") { ... }
    

    The following code will give you the file name from the URL

    $basename = basename($_SERVER['REQUEST_URI']);
    

    So if you have http://mysite.com/index.php it’ll give you index.php

    You can use this in your header.php similarly to how I described above to decide which link to bold.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to include the Zend_Service_Amazon_S3 file by using require_once 'Zend/Service/Amazon/S3.php'; I have
I am trying to write a function that includes a file named header.php in
I am trying to include a .php file that will generate a form for
I am trying to include a .js file into a php file. My folder
I'm trying to link to an external stylesheet using this code: <?php include(/homepages/9/myusername/htdocs/Mobile_Detect.php); $detect
I'm trying to do a bit of fancy/experimental php so that you can include
I am trying to include a very simple header.html to my index.php but it
I'm trying to create a dynamic webpage using include() in PHP. This PHP page
I'm trying to include the header at the top of my pages, but it
I'm trying to cobble together a php style include function for javascript. The route

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.