What are superglobals in PHP?
Superglobal Variables
Superglobal Variables in PHP are predefined global variables. Global variables are variables with global scope, which means that they can be used wherever needed – they do not need to be declared, nor do they need to be marked with global in functions. All superglobal variables are written in all-caps like, $_GLOBALS.
List of Superglobal Variables
All of the superglobal variables act as associative arrays that use a string value as a key to access values. The following is a list of superglobal variables in PHP:
$GLOBALSis the superglobal variable that stores all user-defined global variables. The global variable names act as keys to their values.$_SERVERcontains data about headers, scripts, and paths. The keys to the values in this array are predefined.$_REQUESTstores data input in the form of HTTP POST, GET and Cookies. The keys to this array are defined in the HTTP requests.$_POSTstores data input in the form of POST requests. The keys to this array are defined in the HTTP POST request.$_GEThas data input in the form of GET requests. The keys to this array are defined in the HTTP GET request.$_FILESis a two-dimensional associative array that contains a list of files that were uploaded to the script using the POST method. The keys to this array are the names of the fields uploading the files and the data being accessed. For example,$_FILES[fileUploaded][name]accesses the name of the file being uploaded from the fileUploaded field.$_COOKIESkeeps data input via HTTP Cookies. The keys to this array are defined when the cookies are set.$_SESSIONholds session variables. Session variables can be accessed on multiple pages. This array’s keys are defined by the users when they define session variables.$_ENVcontains information about the environment that PHP is running in. The keys to the values in this array are predefined.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved