bilis_money Posted July 7, 2006 Share Posted July 7, 2006 ok, this question is pretty basic. so i'm sure many of you can give me your thoughts.I've been using this for a year now but still i'm not 100% so sure the purposeof $_SERVER['PHP_SELF'];.all i know about $_SERVER['PHP_SELF']; is to display the results on thesame page as it was.Is this correct thought?PLease if you have good explaination and thoughts pleaseexplain it to me in detail.Or if there is any fundamental purpose of this 'PHP_SELF' thensay it till i get your thought right!Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/13940-php_self-please-give-me-your-opinion-basic-question/ Share on other sites More sharing options...
Daniel0 Posted July 7, 2006 Share Posted July 7, 2006 Hey,The official description is located here description of $_SERVER['PHP_SELF'] from PHP is:[quote]The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/13940-php_self-please-give-me-your-opinion-basic-question/#findComment-54338 Share on other sites More sharing options...
cmgmyr Posted July 7, 2006 Share Posted July 7, 2006 It basically let's you use the page that you are on as a variable.If you are on index.php you can have a for that has action=$_SERVER['PHP_SELF'] so it's like action=index.php It's really helpful if you have a lot of links on one page that go to multiple functions index.php?action=1 index.php?action=2 you can just do $_SERVER['PHP_SELF']."?action=1" $_SERVER['PHP_SELF']."?action=2" so you don't need to type in index.php all the time. You can also change the file name, and your script will still work without recoding it. So if you changed it to index2.php, and if you were using $_SERVER['PHP_SELF'] you wouldn't have to go adding 2's all over your code. You get the point...Hope this helped, and you can do a lot more then just that with it.-Chris Quote Link to comment https://forums.phpfreaks.com/topic/13940-php_self-please-give-me-your-opinion-basic-question/#findComment-54345 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.