PHP superglobals


Introduction

In addition to user defined variables, PHP populates the global namespace with a number of predefined variables called superglobals. They are always available to be accessed from within any function or method, without specifying the global keyword. List of supperglobals is given below −

$GLOBALSReferences all variables available in global scope
$_?SERVERServer and execution environment information
$_?GETHTTP GET variables
$_?POSTHTTP POST variables
$_?FILESHTTP File Upload variables
$_?REQUESTHTTP Request variables
$_?SESSIONSession variables
$_?ENVEnvironment variables
$_?COOKIEHTTP Cookies
$php_?errormsgThe previous error message
$HTTP_?RAW_?POST_?DATARaw POST data
$http_?response_?headerHTTP response headers
$argcThe number of arguments passed to script
$argvArray of arguments passed to script

Updated on: 18-Sep-2020

438 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements