PHP line of code [duplicate]
Possible Duplicate:
How to get URL of current page in PHP
ive been searching all over and i do not know php too well but all im trying to to do is display:none in php when on a certain page (/site/page/).
basically <?php if on this 开发者_JS百科page -->(/page/site/)><?php //echo $this->?><div or span id="dropdown_navigation" style="display:none"></div> <?php endif; ?>
i know that code is all funky but i just wanted to kinda explain what im trying to do in that made up code with no php knowledge. the div id im trying to hide when on a certain page is a drop down menu called "dropdown_navigation"
any help would be greatly appreciated.
thanks.
Alright. You can go like so:
<?php if($_SERVER['REQUEST_URI']=='/the/page.html'){
echo '<div id="dropdown_navigation"...';
} ?>
That should do it. Replace ... with whatever you need. If you need to use a single quote in there, you'll have to escape it by prepending a backslash (i.e. \')
This only works with the relative URL.
There are two global arrays which contain the information about the url:
$_SERVER['REQUEST_URI']
:$_SERVER['QUERY_STRING']
: This will contain the query string something after the ? in the url.
The PHP script would be then :
<?php
if($_SERVER['REQUEST_URI'] == 'your specific page url') {
?>
<div or span id="dropdown_navigation" style="display:none"></div>
<?php } ?>
精彩评论