What returns $ _GET ['key'] if the key is not set?

What returns $ _GET when the index is not set? (Could not find anything in php manual about $ _GET.)

I wrote this to check if $ _GET ['id'] isset - and if it is not, set $ id to false:

<?php $id = (isset($_GET['id'])) ? $_GET['id'] : false ?> 
+6
arrays php get
source share
6 answers

$ _ GET is just an ordinary array, so it behaves exactly like any other array.

This means that it will return a NULL variable and raise a “undefined” notification when a nonexistent index is called.

The only thing you need to know with $ _GET is that it contains unsafe (user-modifiable) data

+14
source share

Set indexes are NULL. Access to them will lead to the fact that the notification will be raised (unless your error level is set to read notifications).

+3
source share
 var_dump($_GET['nonexistent']); // outputs NULL 

http://php.net/manual/en/function.var-dump.php

+1
source share

Here is an example in the manual: PHP: $ _GET .

The relevant part of the sample script is:

 if(isset($_GET["a"])) echo "a is set\n"; 

This part of the script prints "a is set" when a is passed as a parameter through the URL. http: //path/to/script.php? a

+1
source share

If the index is not set, running isset() at that index inside $_GET returns false.

0
source share

$_GET is a superglobal array :

Thus, it follows the rules for accessing array keys:

Attempting to access an array key that was not defined in the same way as accessing any other undefinedvariable: error E_NOTICE message will be published, and the result will be NULL .

0
source share

All Articles