PHP isset

PHP isset() is used to detect whether one or more variables are set, returns TRUE if the variable being detected exists, and FALSE otherwise.


bool isset(mixed var [, mixed var [, ...]])

If more than one variable is detected, the test returns TRUE as long as one of the variables is present.


$var = 1;
if (isset($var)) {
    echo 'variable $var has been set';
} else {
    echo 'variable $var has not been set';

Run the example output:

variable $var has been set
  • isset() can only be used to detect variables, passing any other parameters will cause parsing errors.
  • isset() is a language construct, not a function, so it can not be called by a variable function.

The following condition, isset() returns FALSE:

// The variable is set to null
$var = null;
// unset() was released by the variables
// The class variable is declared by the var keyword, but has not been set
var $var;

isset() returns TRUE if:

$var = " ";
$var = array();
$var = 0;
$var = false;

Copyright 2014-2017 by All Rights Reserved.