ceddy Posted April 28, 2007 Share Posted April 28, 2007 Im a bit of a newbie to php, ive already got something working except i would like to be able to say if page = mypage.php (followed by anything) then print this eg: mypage.php? mypage.php?&this_could_be_anything what I am using now is: <?php $myIndexPage = "index.php"; $myDomainName = "mydomain.com"; $_SERVER[HTTP_HOST] = strtolower($_SERVER[HTTP_HOST]); if($_SERVER[REQUEST_URI]=="/".$myIndexPage or $_SERVER[REQUEST_URI]=="/".$myIndexPage."/" or $_SERVER[REQUEST_URI]=="/" or $_SERVER[REQUEST_URI]=="/?currency=EUR" or $_SERVER[REQUEST_URI]=="/?currency=GBP" or $_SERVER[REQUEST_URI]=="/?currency=USD"){ ?> you can see ive had to add the currency querystrings to the address... id like to be able to tell it if it begins with index.php as well as index.php with a querystring following it to print something different... thanks Link to comment https://forums.phpfreaks.com/topic/49126-if-page-equals/ Share on other sites More sharing options...
Barand Posted April 28, 2007 Share Posted April 28, 2007 $this_page = basename($_SERVER['PHP_SELF']); Link to comment https://forums.phpfreaks.com/topic/49126-if-page-equals/#findComment-240709 Share on other sites More sharing options...
ceddy Posted April 28, 2007 Author Share Posted April 28, 2007 doesnt that just figure out the current web url? What I want is to be able to say on the index page print a different header then the rest of my site -- which is working with my above code... except for sessions because they are random and different for each user so like if page = index.php*... print this else print that i just dont know what to use for that *... to tell it whatever follows specified page Link to comment https://forums.phpfreaks.com/topic/49126-if-page-equals/#findComment-240721 Share on other sites More sharing options...
Warptweet Posted April 28, 2007 Share Posted April 28, 2007 Pretend it's index.php?something=pagename if ($_GET['something'] == 'pagename'){ do stuff here } if ($_GET['????'] == '??????'){ will get whats after the ? on your url. Change $_GET['????'] to $_SERVER['REQUEST_URL'] if you want to see the name of the file your seeing. Link to comment https://forums.phpfreaks.com/topic/49126-if-page-equals/#findComment-240723 Share on other sites More sharing options...
ceddy Posted April 29, 2007 Author Share Posted April 29, 2007 not sure i follow the $_GET['? ? ?'] line (without spaces) you said.. that is only an example? Id have to fill the ?'s with variables? or will that grab the variables? Cause I could immagine that could work if i could say something along the lines of $get_variable = $GET['???'] == '????'; then if ($_SERVER[REQUEST_URI]=="/index.php" . $get_variable) { echo 'Something'; } however i cant get that statement to work at all Link to comment https://forums.phpfreaks.com/topic/49126-if-page-equals/#findComment-240743 Share on other sites More sharing options...
ceddy Posted April 29, 2007 Author Share Posted April 29, 2007 well i thought this would work... but its not for some reason... if(($_SERVER['REQUEST_URI']=="/") && (isset($_GET['currency']))){ echo 'Test'; } which seems it would work from this url http://www.mydomain.com/?currency=USD because the below code does work... $get_variable = 'no querystring'; if ( isset( $_GET['name'] ) ) { $get_variable = 'with name querystring'; echo $get_variable; } elseif ( isset( $_GET['currency'] ) ) { $get_variable = 'with currency querystring'; echo $get_variable; } else { echo $get_variable; } i even tried assigning a value if the querystring existed and doing this... with no joy if(($_SERVER['REQUEST_URI']=="/") && ($get_variable==1)){ echo 'Test'; } any ideas why this isnt working?? Link to comment https://forums.phpfreaks.com/topic/49126-if-page-equals/#findComment-240790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.