$_SERVER['PHP_SELF']; What does it do

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
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

$_SERVER['PHP_SELF']; What does it do

Post by Kingo »

Hello,
I just wanted to know what this one ($_SERVER['PHP_SELF'];) will do.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

always think about
google or
php.net

but it basically "reload" the same page your in to send information to server so for exemple when you filla form instead of loading another ppage it load the same one wqith the mistake in red next to the badly entered field.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Alternatively, you can pass parameteres through the address bar. For instance, if a page loads and finds a cookie on a user's machine, you can refresh the page to something like $_SERVER[PHP_SELF]?login=1&sessid={SESS_ID}. Stuff like that. Basically, it saves you writing index.php or pagename.php and allows you to put the above line in an include file and use it throughout your site. Hope that helped!

Good luck!
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Draco_03 wrote:always think about
google or
php.net

but it basically "reload" the same page your in to send information to server so for exemple when you filla form instead of loading another ppage it load the same one wqith the mistake in red next to the badly entered field.
No it doesn't.
It's a part of an array ($_SERVER array) that contains the value of the current page name (ie. default.php). Nothing more, nothing less.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

just a variable to help you to get the current page name. By the way, lilpunk that link in your sig helped me soo much thanks ;-)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Glad to hear it mudkicker, I hoped making it would help at least a few people, and I've gotten around 130 unique hits, so I guess it has. :)
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

:) well, it helped cos i got stuck on some point by installation. and it guided me very good. At least it helped me :)
Post Reply