\"$PHP_SELF\" <----- Need some help with that.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
darkstarskaterboy
Forum Newbie
Posts: 5
Joined: Tue May 31, 2005 12:00 am
Location: Pa

\"$PHP_SELF\" <----- Need some help with that.

Post by darkstarskaterboy »

What is this, what does it do, anything that you could tell me would be helpful.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

$PHP_SELF is a predefined variable that contains filename of the current running script.

In the addy "http://example.com/example.php", $PHP_SELF would contain "/example.php"

"http://example.com/folder/another.php" => "/folder/another.php"
"http://example.com/again.php#anchor" => "/again.php"
"http://example.com/yetagain.php?var=1" => "/yetagain.php" (I think)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Basically it is mainly used for portability purposes. For example, as shown in the form above, that would work on any server instead of having to manually changed it every time.
darkstarskaterboy
Forum Newbie
Posts: 5
Joined: Tue May 31, 2005 12:00 am
Location: Pa

I dont' know where it is defined though.

Post by darkstarskaterboy »

I can't find where it is defined,, so i don't know what it is, so it is giving me an error.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

take a look at

Code: Select all

print_r($_SERVER);
take a look over at PHP_SELF
Post Reply