HTTP Variables

PHP HTTP Variables are pre-defined superglobal variables, that provide access to data being passed and / or store through HTTP protocol.

The $_GET Array

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

The $_POST Array

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

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.

The $_SESSION Array

This YouTube video was created by Steve Griffith.

The $_SERVER Array

This YouTube video was created by Steve Griffith.