Saturday, May 5, 2012

Explain: php_self or $_SERVER['PHP_SELF'] Usage

Can you explain usage of predefined variables called $_SERVER['PHP_SELF']?

PHP programming language provides a lots of predefined variables. Your php script can access a large number of such predefined variables.

$_SERVER array

$_SERVER is an array defined in PHP and it stores information about your server and execution environment information.

$_SERVER['PHP_SELF'] variable

This array element points out the filename of the currently executing script. For example, if you run www.cyberciti.biz/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.
 
....
<div class="forumform">
<form action="' . $_SERVER[PHP_SELF]. '" method="post" onSubmit="return checkForm()" name="pforum">
....
 


No comments:

Post a Comment