PHP isset() function

Description

Checking Whether a Variable Is Set: isset()

Syntax

PHP isset() function has the following syntax.

isset($variableName);

Parameter

  • $variableName - variable to check

Return

The isset() function returns true or false depending on whether the variable has a value assigned to it.

Example

Is the variable check


<?PHP/*  w w  w  .j  av  a2s .c  o  m*/
$foo = 1; 
if (isset($foo)) { 
       echo "Foo is set\n"; 
} else { 
       echo "Foo is not set\n"; 
} 

if (isset($bar)) { 
       echo "Bar is set\n"; 
} else { 
       echo "Bar is not set\n"; 
} 
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions