$_SERVER['PHP_SELF'] vs $_SERVER['REQUEST_URI']

Posted under » PHP on 4 April 2010

$_SERVER['REQUEST_URI'] just the file name. /file.php. This may not be the file. It will give your the full url shown on the browser's address bar in case you are rewriting it.

$_SERVER['PHP_SELF'] has more path info (in some servers) but basically the same as above. /subdir/file.php

$_SERVER['SCRIPT_FILENAME'] has all the info. /Users/user/Sites/file.php

$_SERVER['SCRIPT_NAME'] kinda the same as above.. test it out if it suits your purposes.

$_SERVER['DOCUMENT_ROOT'] has only the path. /Users/user/Sites/

$_SERVER['HTTP_HOST']; just the domain name. www.anoneh.com.

$_SERVER['HTTP_REFERER']; where you come from. Have some security applications too if you think about it.

$_SERVER['REMOTE_ADDR']; the client's IP.

web security linux ubuntu GIT svn Raspberry apache mysql php drupal cake symfony javascript Ajax css