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 8335923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:49:18+00:00 2026-06-09T03:49:18+00:00

I am dealing with the following kind of choppy code while trying to figure

  • 0

I am dealing with the following kind of choppy code while trying to figure this out.

<?php $curURL = ROOT.$_SERVER['REQUEST_URI']; ?>
            <li><a href="<?php $href = APP_ROOT; echo $href; ?>" class="<?php if($href == $curURL) { ?>main_active<?php } ?>">HOME</a></li>
            <li><a href="<?php $href = APP_ROOT.'about'; echo $href; ?>" class="<?php if($href == $curURL) { ?>main_active<?php } ?>">ABOUT</a></li>
            <li><a href="<?php $href = APP_ROOT.'portfolio'; echo $href; ?>" class="<?php if($href == $curURL) { ?>main_active<?php } ?>">PORTFOLIO</a></li>
            <li><a href="<?php $href = APP_ROOT.'services'; echo $href; ?>" class="<?php if($href == $curURL) { ?>main_active<?php } ?>">SERVICES</a></li>
            <li><a href="<?php $href = APP_ROOT.'blog'; echo $href; ?>" class="<?php if($href == $curURL) { ?>main_active<?php } ?>">BLOG</a></li>
            <li><a href="<?php $href = APP_ROOT.'contact'; echo $href; ?>" class="<?php if($href == $curURL) { ?>main_active<?php } ?>">CONTACT</a></li>

The result I am currently getting is that if I am on the selected pages url (ex. http://localhost/myapp/index/) then it will change the css style accordingly. What I am looking to have happen is that the css style will remain changed even if I am on a sub url of that page (ex. http://localhost/myapp/index/dosomething/). Ive been banging my head against the wall on this one for a while.

  • 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-09T03:49:20+00:00Added an answer on June 9, 2026 at 3:49 am

    This is how I do it on one of my sites. This is a sample that applies a class to an active link, but the idea is the same…

    PHP

    $current_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    $fullPath = parse_url($current_url, PHP_URL_PATH);
    $prepare = explode('/',$fullPath);
    $path = "/" . $prepare[1];
    

    HTML

    <li><a href="location.php"<?php if($path == $thePath) { echo 'class="active"';}?>>Link Title</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out the best practice for dealing with the following situation:
Background: In some PHP code dealing with a 3rd party web-service, the following code
This is the following code example from Twisted for dealing with receiving of multicasts.
I'm dealing with a large code base that uses the following construct throughout class
I am dealing with some auto-generated XSLT code. It contains the following: string(string(.)) number(string(.))
Dealing with some legacy code and in trying to get a poorly designed database
the code I'm dealing with has loops like the following: bistar = zeros(numdims,numcases); parfor
The following example resembles a similar problem that I'm dealing with, although the code
Consider the following code dealing with const references: const int & func (const int
I am having some difficulty dealing with memory leaks in the following code. Using

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.