SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2003
    Location
    scarborough
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Detect name of webpage you are on

    How do you return the webpage you are on right now...

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    Checkout: parse-url

  3. #3
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Uhm, "Name"? that's a bit vague... do you mean the URL (if so $_SERVER contains mutliple versions of that), or the TITLE (which isn't sent to be parsed)...

  4. #4
    Life is not a malfunction gold trophysilver trophybronze trophy
    TechnoBear's Avatar
    Join Date
    Jun 2011
    Location
    Argyll, Scotland
    Posts
    6,411
    Mentioned
    273 Post(s)
    Tagged
    5 Thread(s)
    Did you mean something like this:
    Code PHP:
    <?php $currentPage =  basename($_SERVER['SCRIPT_NAME']); ?>
    <ul>
    	<li <?php if ($currentPage == 'index.php') {echo 'class="selected"';} ?>><a href="index.php">Home</a></li>
    	<li <?php if ($currentPage == 'prog.php') {echo 'class="selected"';} ?>><a href="prog.php">Festival Programme</a></li>
    	<li <?php if ($currentPage == 'events.php') {echo 'class="selected"';} ?>><a href="events.php">Other Events</a></li>
    	<li <?php if ($currentPage == 'reports.php') {echo 'class="selected"';} ?>><a href="reports.php">Past Events</a></li>
    	<li <?php if ($currentPage == 'info.php') {echo 'class="selected"';} ?>><a href="info.php">Useful Information</a></li>
    	<li <?php if ($currentPage == 'contact.php') {echo 'class="selected"';} ?>><a href="contact.php">Contact</a></li>
    </ul>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •