PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

$_SERVER['PHP_SELF']

The $_SERVER['PHP_SELF'] variable tells you the file name of the current script.

Use as follows:

echo $_SERVER['PHP_SELF'];

Example 1:

Suppose the url you are accessing is http://www.somesite.com/play.php, the if you echo $_SERVER['PHP_SELF'], you will get:

/play.php

Note that any url parameters are discarded. For example, for url http://www.somesite.com/display.php?id=345, using $_SERVER['PHP_SELF'] will return just:

/display.php

Using the $_SERVER['PHP_SELF'] on this page will output the following file name of this script:

/e/1/php/php-self.php

See also:

$_SERVER['HTTP_REFERER']
$_SERVER['HTTP_USER_AGENT']
$_SERVER['REMOTE_ADDR']
$_SERVER['REQUEST_URI']
$_SERVER['DOCUMENT_ROOT']
$_SERVER['HTTP_HOST']
$_SERVER['QUERY_STRING']
$_SERVER['SCRIPT_FILENAME']




Home | Privacy Policy | Terms Of Use | Contact Us