PHP Global Variable $_GET

PHP $_GET is a super global or automatic global variable. It uses to collect form data after submitting a form with the “get” method. It passes data in an associative array. Form “get” method passes an associative array of data via URL and PHP $_GET method collects those data.

So, $_GET can collect data that come via URL.

So, $_GET can populate all URL query strings (aka, URL parameter).

Some important points:-

  1. The GET method is restricted to sending up to 1024 characters only.
  2. We cannot pass any sensitive data like:- user name, password, etc. using the GET method.
  3. We cannot pass any binary data like images, pdf, word documents, etc. using the GET method.
  4. GET method can be useful in pagination, AJAX calls, etc.



$name = $_GET[‘name’];

echo $name;

//output:- ksh

HTML Form Example:-


if( $_GET[“animal”] || $_GET[“type”] ) {

echo “Your “. $_GET[animal]. “<br />”;

echo “Animal Type  “. $_GET[type];






<form action = “<?php $_PHP_SELF ?>” method = “GET”>

Animal :  <input type = “text” name = “animal” />

Type :  <input type = “text” name = “type” />

<input type = “submit” />


Read Also:-


PHP Global Variable $_SERVER


PHP predefined variables

How to code a PHP application

For more detail about variables please see manual

Share with:

Leave a Reply

Connect with:

Verified by ExactMetrics