Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2003, 02:59 AM
pb7 pb7 is offline
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default $PHP_SELF

Hello,
this is probably a trivial question, especially since I sort of understand what $PHP_SELF represents, but could anybody confirm what it exactly does. It is used in Wrox's "Beginning PHP", yet I can't find any formal description of the varaible (?). Is it an environment variable like $HTTP_POST_VARS? no book seems to devote even a short paragraph to it. Do you know of any source that would list other such variables and give a short description of each?
Cheers!:)

Philippe
__________________
Philippe
 
Old September 9th, 2003, 11:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

$PHP_SELF is a global variable that's ONLY available if you have "register_globals = on" set in your PHP configuration (php.ini). This variable should be accessed via $_SERVER['PHP_SELF'].

That said, PHP_SELF is a string that contains the relative URL path of the script being executed. The most common use for it is to insert PHP_SELF into links or form actions to direct the user to the same page they are leaving.

Scripts that generate a form generally receive that form's input, so that if any validation steps fail, it can simply be triggered to regenerate the form.

It's useful to have links return to the same page that you just left for a multitude of reasons. Take, for example, a table of data that you'd like to sort by various columns. Each column header is a link to the same page specifying the column by which to sort.

For more info, read the register_globals FAQ and the manual page about reserved variables.

  http://p2p.wrox.com/archive/beginnin...2002-11/17.asp
  http://www.php.net/reserved.variables
  http://www.php.net/variables.predefined


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
error HREF=$PHP_SELF?action broccolo PHP Databases 5 December 26th, 2004 10:07 AM
error in PHP_SELF?action= broccolo PHP Databases 1 November 23rd, 2004 10:47 AM
error in <form action='{$_SERVER['PHP_SELF']} lanita PHP How-To 1 July 27th, 2004 01:07 AM
PHP_SELF dungey Beginning PHP 3 April 12th, 2004 11:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.