What are the predefined variables in PHP?

PHP: What are the predefined variables in PHP?

There are a handful of predefined variables in PHP. They include:

$GLOBALS — References all variables available in global scope

$_SERVER — Server and execution environment information

$_GET — HTTP GET variables

$_POST — HTTP POST variables

$_FILES — HTTP File Upload variables

$_REQUEST — HTTP Request variables

$_SESSION — Session variables

$_ENV — Environment variables

$_COOKIE — HTTP Cookies

$php_errormsg — The previous error message

$HTTP_RAW_POST_DATA — Raw POST data

$http_response_header — HTTP response headers

$argc — The number of arguments passed to script

$argv — Array of arguments passed to script

The most commonly used ones, in my opinion, are $_GET, $_POST, $_SERVER, $_FILES, $_SESSION and $_COOKIE (so, the majority of them!)

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about What are the predefined variables in PHP?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the PHP language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

What are the SPL data structures

How to check if a (blade) view file exists

How to check if two strings are anagrams in PHP?

How to query mysql using PDO in PHP?

What are some ways you can log debug messages and data in JS?

How to find out which php.ini file PHP is using?

An overview of every main PHP array function

How to add the default charset to UTF-8 in .htaccess

How to change the order that migrations happen?

What is Agile software development?