Jump to content

Recommended Posts

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

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.

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.