Jump to content

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

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

}

Link to comment
https://forums.phpfreaks.com/topic/187765-_serverrequest_uri/#findComment-991343
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.