I am learning PHP. Can anyone please explain me the usage of Isset function in PHP with example. I have checked a few tutorials on internet but unable to understand them. Thanks
isset()
only returns boolean value i.e TRUE or FALSE. Most oftent used to check if the variable is assinged or not
Let we check like this
Case 1 :
$a = '';
var_dump (isset($a)); // Will return TRUE
Case 2 :
$b = NULL;
var_dump (isset($a)); // Will return FALSE
Case 3 :
$c = 0;
var_dump (isset($c)); // Will return TRUE
Case 4 :
var_dump (isset($d)); // Will return FALSE
//oops i did'nt assing the variable.
Hope this helped you .
check these links
http://php.net/manual/en/function.isset.php
http://www.w3resource.com/php/function-reference/isset.php
A simple explanation is, it is used to check whether a variable is set or not
Mostly used for form elements like check boxes . If the box is checked isset() returns true if its not returns false. Ca also be used to check if a variable has something assigned to it .