HTTP Variables
PHP HTTP Variables are pre-defined superglobal variables, that provide access to data being passed and / or store through HTTP protocol.
$_GET
Array
The This YouTube video was created by Steve Griffith.
The $_GET
superglobal array is an associative array of variables passed to the current script via the URL parameters.
<?php
//
echo 'Hello, '.$_GET['name'];
?>
Assuming the URL https://example.com?name=World
, the above example will output something similar to:
Hello, World
$_POST
Array
The This YouTube video was created by Steve Griffith.
The $_POST
superglobal array is an associative array of variables passed to the current script via the HTTP POST method when receiving data from a form.
<?php
//
echo 'Hello, '.$_POST['name'];
?>
Assuming the following form was submitted:
<form method="post">
<input type="text" name="name" value="World">
</form>
The above example will output something similar to:
Hello, World
$_COOKIE
Array
The This YouTube video was created by Steve Griffith.
The $_COOKIE
superglobal array is an associative array of variables passed to the current script via HTTP Cookies, which can be defined using the setcookie()
function.
$_SESSION
Array
The This YouTube video was created by Steve Griffith.
$_SERVER
Array
The This YouTube video was created by Steve Griffith.