mpempas Posted January 8, 2010 Share Posted January 8, 2010 Hello, im using this command ($_SERVER['REQUEST_URI']) when visiting mysite.com/forum/* to load diferent thinks than mysite.com , mysite.com/news/ Here is my code which ive try everything but still cant get it work. If (strpos($_SERVER[’REQUEST_URI’], "/forum/") == 1) { i want when im not visiting /forum/* do load diferent thinks } Thank you Quote Link to comment https://forums.phpfreaks.com/topic/187765-_serverrequest_uri/ Share on other sites More sharing options...
i8badhaggis Posted January 8, 2010 Share Posted January 8, 2010 let me understand this correctly. there will not be the string "/forum/" in your url which is when you'll run that code if so then I think what you want actually is If (!strpos($_SERVER[’REQUEST_URI’], "/forum/")) { //will occur when /forum/ is not in your url } Quote Link to comment https://forums.phpfreaks.com/topic/187765-_serverrequest_uri/#findComment-991343 Share on other sites More sharing options...
mikesta707 Posted January 8, 2010 Share Posted January 8, 2010 strpos doesn't return boolean false, but a value that evaluates to false (IE 0, or "") so in order to do what the second poster said, you would want If (strpos($_SERVER[’REQUEST_URI’], "/forum/") === false) { alternatively, you can do !== trueg. Take a look at the manual for more info on this Quote Link to comment https://forums.phpfreaks.com/topic/187765-_serverrequest_uri/#findComment-991348 Share on other sites More sharing options...
mauricederegt Posted June 15, 2011 Share Posted June 15, 2011 I have a similar problem: I have tried the following: // We're NOT on the home page if (strpos($_SERVER['REQUEST_URI'], "/games/mahjong/mahjong.php") >= 0) { $style = "display: none"; } else { $style = "display: inline"; } But if I go to /games/mahjong/mahjong.php?layout it doesn't change the style. I've echoed: echo $_SERVER['REQUEST_URI']; and it changes to /games/mahjong/mahjong.php?layout so why isn't the style set to inline? I also tried: // We're NOT on the home page if (strpos($_SERVER['REQUEST_URI'], "/games/mahjong/mahjong.php") === false) etc etc But this results just in NOT hiding (show style = display: inline) Kind regards, Maurice Quote Link to comment https://forums.phpfreaks.com/topic/187765-_serverrequest_uri/#findComment-1230019 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.