$_SERVER is an array defined in PHP and it stores information about your server and execution environment information.
$_SERVER['PHP_SELF'] is an array element points out the filename of the currently executing script. For example, if you run www.example.com/index.php, $_SERVER['PHP_SELF'] would be /index.php. This is relative to the document root. This is useful to referring HTML forms and other element.
for example:
ANL
2 comments:
The action="#" also points to the current document. What's the difference if I use the $_SERVER['PHP_SELF'] variable?
Yup, you are right. action="" will also point to the current document. According to my knowledge, the advantage of using this array is:
We can use one form in multiple pages including it. It will translate to a URL
of the current page and so will call its own page regardless of where it is used.
Hope, this explanation make sense.
Post a Comment