Re: getting current page url [RESOLVED]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Schalk wrote:


Jochem Maas wrote:

do a search $_SERVER['PHP_SELF'] - it should answer all your question.

if in doubt a var_dump() can do wonders (in this finding out what kind of
info is generally available, e.g.:

<?php

echo '<pre>';
var_dump($_SERVER, $_REQUEST, $_ENV, $_POST, $_GET);

Thanks Jochem,

no probs - only by looking at your code I suspect your not all that clear as to
what it does *exactly* and/or why it works (I may be wrong).

what it does is check if $_SERVER['PHP_SELF'] equate to true (i.e. not empty - which it
never is) and then check whether $_SERVER['QUERY_STRING'] equates to false,
which it might or might not but is probably not a basis on which to decide
which menu to show.

also breaking in and out of php with <?php ?><?php ?> is a bad idea - it sucks to
look at and is a waste of cpu cyles - minimal gains, but good habits should be encouraged
early.


A combination $_SERVER['PHP_SELF'] and $_SERVER['QUERY_STRING'] did the trick:

<?php      if(($_SERVER['PHP_SELF']) && (!$_SERVER['QUERY_STRING'])) {
       $current_nav = "includes/home_nav.php";
   } else {
       $current_nav = "includes/inside_nav.php";
   }
   ?>
   <?php include($current_nav); ?>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux