Home Internet PHP Tutorial – SuperGlobals -($_GET ) Global Variable

PHP Tutorial – SuperGlobals -($_GET ) Global Variable


PHP – $_GET  Variable

In php , $_GET is a superglobal or a gobal variable . It is also a pre-defined variable just as $_POST . It is used to get the value from script using GET method . When user input the value in text box then variable get the value from text box analyze it and return the result .

In $_GET variable there is no need to define it as needed in $_POST . User can directly is anywhere in php code .There is no need to do global $variable; to access it within functions or methods.



Input values are displayed in the web browser . This is the reason using this variable is not secured in many cases .


<form method="get" action="index.php">
<input type="text" name="name" />
<input type="submit" />
echo $_GET['name'];

Result of upper code is as in following image 

$_GET variable result
$_GET variable result


As seen in the image , when user type input in text box and click submit button then input value is also shown in web browser . This is a demerit of $_GET[] variable . $_GET is not useful for form validations , login forms and other security check forms.

READ ALSO : -  PHP SuperGlobals - $_SERVER Global Variable

But this not means $_GET and GET method is not useful . It is not secure but still it is very usesfull in many applications. Even world’s most popular search engine Google is also use GET method for get user input and display results . In is very useful for webpage search any non security required php forms .

Learn more about _GET variable click here .