Jump to content

Script called from root or from a subfolder


Travellingman

Recommended Posts

Hi all. New here. From Sweden so excuse my bad grammar.   :-X

 

Can someone please help me with this script?

 

You send in: example: '/about' or '/service' or an empty string: It matches from the URL and if it finds it it returns true.

 

Now I would very much like it to work out if Im in the root folder or not, if you send in an empty string.

 

function isurlcurrentpage($url = "")
   if ($url != "") {
      if(strpos($_SERVER['PHP_SELF'], $url) == false) {
         return false;
      }else{
         return true;
      }
   }else{
   // PSEUDOCODE
   // Nothing has been sent in. Shall we return true or false?
   // [b]If this script is called from a page in the rootfolder - Return true.[/b] Example: 'domain.com/somewhere.php'
      return true;
         
   // [b]Is called from a subcatalog? - Return false[/b] Example: 'domain.com/about'
      return false;
   }
         
}

 

A little help please?  :)

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.