Hi,
I'm wondering what the $_GET function returns when the paramater
checking for being passed has not been declared or listed in the
address bar address entered.
For example
$idd = $_GET['id'];
what would the value of $idd be if in the address bar:
index.php?var1=5&var2=6
id=val
is not found ?
2 replies to this topic
#1
Posted 06 September 2011 - 02:42 PM
|
|
|
#2
Posted 06 September 2011 - 04:50 PM
return nothing (well it return null)
so you should always check is the variable exist with
so you should always check is the variable exist with
if (isset($_GET['id'])) {
...
}
#3
Posted 06 September 2011 - 08:04 PM
Yes, $_GET (in the appropriate CGI context) will always be an array with zero elements, so it does exist. However if you call a non-existent array index then it will return NULL (which in PHP is considered to be not set)
You can always verify these qualities yourself with the var_dump function:
This is why isset() is important.
You can always verify these qualities yourself with the var_dump function:
<?php var_dump($foo['a']); //NULL, $foo does not exist var_dump($_GET['non-existant-id']); //NULL, $_GET exists however the id does not. ?>
This is why isset() is important.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









