Re: getting current page url [RESOLVED]
| From: | Jochem Maas | Date: | Fri, 28 Apr 2006 14:21:12 +0000 |
| Subject: | Re: getting current page url [RESOLVED] | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235001@lists.php.net to get a copy of this message | ||
Schalk wrote:
Jochem Maas wrote: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.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,
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); ?>