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

  • SEARCH
  • Home
  • 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 7497085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:55:42+00:00 2026-05-29T18:55:42+00:00

I included my header in every page which also contains the navigation which leads

  • 0

I included my header in every page which also contains the navigation which leads to the problem on how to add an active class to each nav element if the specific link gets clicked.

I found a working solution on the net.

I put this in my index.php on top:

<?php basename($_SERVER["REQUEST_URI"]) ?>

For each link I do this:

<li><a <?php if (basename($_SERVER["REQUEST_URI"]) == "index.php") echo " class='active' ";?> href="index.php">Start</a></li>

Everything works fine but of course it doesn’t work at the very start if you just enter the domain name like:

www.mydomain.com

I tried:

if (basename($_SERVER["REQUEST_URI"]) != " ")

But then it will stick with the active class all the time.

How can I add something like “if it’s the root just give the “Start” link and only then the active class?

  • 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-05-29T18:55:45+00:00Added an answer on May 29, 2026 at 6:55 pm

    You could try to use try $_SERVER['PHP_SELF'] instead of $_SERVER["REQUEST_URI"]

    ps: if you want to know more about php configuration (including the values of $_SERVER and others) create a php file with <?php phpinfo(); ?> and call it from browser.

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

Sidebar

Related Questions

I have a set of links in header.asp which is included on every page;
I have a header control which is included in every page. I create dynamic
I've written a filter class to add a P3P header to every page. I
If a header file (.h) included in the source file has also been included
My PHP site has header,body,footer files that are included into the INDEX.PHP page. On
Assume that there's no problem with my header file and some included library. I'm
I have an alertview which displays fine. In my header I've included the UIAlertViewDelegate,
The following is the beginning of header.php, which is a file included at the
I'm currently using include 'header.php' and include 'footer.php' in every page, and as far
I'd like to have the same header and footer on every page only with

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.