SirChick Posted January 15, 2008 Share Posted January 15, 2008 As with : $_SERVER['PHP_SELF'] You can get the name of the file. And the directory. Now my question is say i have this: Echo $_SERVER['PHP_SELF']; And it displays: /foldername/phpfile.php Is there a way using if statements to check that the file the user is view is in that exact folder name rather ? But the php file name after is totally irrelevant? Something like: "If ($_SERVER['PHP_SELF'] == '/foldername/...')" Is it possible if so what is the best way? Link to comment https://forums.phpfreaks.com/topic/86217-solved-directory-check/ Share on other sites More sharing options...
KrisNz Posted January 15, 2008 Share Posted January 15, 2008 ummm, the dirname() function? Link to comment https://forums.phpfreaks.com/topic/86217-solved-directory-check/#findComment-440368 Share on other sites More sharing options...
SirChick Posted January 15, 2008 Author Share Posted January 15, 2008 Well from what i read about that function that is for creating a directory not "getting" the directory of the php file the user is viewing . My explanation was poor so ill try a second time. (Damn thing would not let me edit my post!) With the PHP_SELF function it gives you the directory of the php file that the user is viewing. What i need to do is use an If statement to check that the php is in the directory i want it to be in if you get me? So say the user views "test.php" PHP_SELF would show "/foldername/test.php" Now in an if statement it wouldn't be smart to have 100's of if statements to check that each page was in the foldername because i would have to have an If statement for every php file name so i need to make it only check as far as the folder name then after that it is not important. So i need a way for it to only read the directory but not the php file name so the result will show: if(PHP_SELF == /foldername/...) the " ... " represents "anything after that" is valid. Link to comment https://forums.phpfreaks.com/topic/86217-solved-directory-check/#findComment-440388 Share on other sites More sharing options...
KrisNz Posted January 15, 2008 Share Posted January 15, 2008 are you sure you weren't reading about mkdir()?? echo dirname($_SERVER['PHP_SELF']); Link to comment https://forums.phpfreaks.com/topic/86217-solved-directory-check/#findComment-440395 Share on other sites More sharing options...
SirChick Posted January 15, 2008 Author Share Posted January 15, 2008 Oh so thats how its done.. i read through that php page of everyone's suggestions could not find sumin as simple as what you showed. Its always overly complicated Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/86217-solved-directory-check/#findComment-440402 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.