Jump to content

$_SERVER['REQUEST_URI'];


mpempas

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/187765-_serverrequest_uri/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/187765-_serverrequest_uri/#findComment-991348
Share on other sites

  • 1 year later...

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

Link to comment
https://forums.phpfreaks.com/topic/187765-_serverrequest_uri/#findComment-1230019
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.