strpos Url

Discussion in 'PHP' started by Silver89, May 21, 2008.

  1. #1
    I'm trying to include a file if the url includes /forum/ with the following code but I can't seem to get it too work.

    
    $urlForum = strpos($_SERVER["REQUEST_URI"], "/forum/");
    	
    if ($urlForum == false)
    
    {require_once 'memberpanel.php';}
    	
    else
    {require_once 'forumPanel.php';}
    
    
    PHP:

     
    Silver89, May 21, 2008 IP
  2. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #2
    Untested, but please try this :)

    
    if (stristr($_SERVER["REQUEST_URI"], "/forum/")) {
       require_once 'forumPanel.php';
    } else {
       require_once 'memberpanel.php';
    }
    
    
    PHP:
    You can use some regular expression, but in this case, stristr is faster.
     
    xrvel, May 22, 2008 IP
    Silver89 likes this.