Monday, June 8, 2026
HomeLanguagesPHP | isset() Function

PHP | isset() Function

The isset() function is an inbuilt function in PHP which is used to determine if the variable is declared and its value is not equal to NULL.

Syntax:

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

Parameters: This function accept one or more parameter as mentioned above and described below:

  • $var: It contains the variable which need to check.
  • $…: It contains the list of other variables.

Return Value: It returns TRUE if var exists and its value not equal to NULL and FALSE otherwise.

Below examples illustrate the isset() function in PHP:

Example 1:




<?php
  
$str = "neveropen";
  
// Check value of variable is set or not
if(isset($str)) {
    echo "Value of variable is set";
}
else {
    echo "Value of variable is not set";
}
  
$arr = array();
  
// Check value of variable is set or not
if( !isset($arr[0]) ) {
    echo "\nArray is Empty";
}
else {
    echo "\nArray is not empty";
}
  
?>


Output:

Value of variable is set
Array is Empty

Output:

Example 2:




<?php
  
$num = 21;
var_dump(isset($num));
  
$arr = array(
        "a" => "Welcome",
        "b" => "to",
        "c" => "neveropen"
    );
  
var_dump(isset($arr["a"]));
var_dump(isset($arr["b"]));
var_dump(isset($arr["c"]));
var_dump(isset($arr["Geeks"]));
  
?>


Output:

bool(true)
bool(true)
bool(true)
bool(true)
bool(false)

Reference: https://www.php.net/manual/en/function.isset.php

RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6895 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7018 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS