Tuesday, June 12, 2012

PHP, difference between $_SERVER['PHP_SELF'] and $_SERVER['REQUEST_URI']



What is the difference  between $_SERVER['PHP_SELF'] and   $_SERVER['REQUEST_URI'] in PHP?
For example
 <form method="post" action="<?php  echo $_SERVER['PHP_SELF']; ?>">
and 
 <form method="post" action="<?php  echo $_SERVER['REQUEST_URI'];  ?>">

  $_SERVER['PHP_SELF'] returns the file of current webpage,   $_SERVER['REQUEST_URI'] return the file name with variables.

For Example:  www.example.com/index.php?a=test

$_SERVER['PHP_SELF'] returns  index.php, while
$_SERVER['REQUEST_URI'] returns index.php?a=test.

Reference:

No comments:

Post a Comment