Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between: $_SERVER['SCRIPT_NAME'] and $_SERVER['PHP_SELF']

Tags:

php

What is the difference between:

$_SERVER['SCRIPT_NAME']

and

$_SERVER['PHP_SELF']

Thank you.

like image 250
Jim Avatar asked Jun 24 '11 16:06

Jim


People also ask

What is $_ SERVER [' PHP_SELF ']?

$_SERVER['PHP_SELF'] Returns the filename of the currently executing script. $_SERVER['GATEWAY_INTERFACE'] Returns the version of the Common Gateway Interface (CGI) the server is using.

What is the usage of $_ SERVER [' Server_addr ']?

The $_SERVER['SERVER_ADDR'] returns the IP address (Internet Protocol address) of the host server. Following php code used $_SERVER['SERVER_ADDR'] to display the IP address of the host server.


1 Answers

They should contain the same information. However, historically and technically speaking, there is a difference between the two.

SCRIPT_NAME is defined in the CGI 1.1 specification, and therefore is a standard. This means it should be available no matter what scripting language you're using.

PHP_SELF is implemented directly by PHP, and as long as you're programming in PHP, it will be there.

like image 72
Michael Irigoyen Avatar answered Sep 24 '22 07:09

Michael Irigoyen