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 = "GeeksforGeeks"; // 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"; } ?> |
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" => "GeeksforGeeks" ); var_dump(isset($arr["a"])); var_dump(isset($arr["b"])); var_dump(isset($arr["c"])); var_dump(isset($arr["Geeks"])); ?> |
bool(true) bool(true) bool(true) bool(true) bool(false)
Reference: https://www.php.net/manual/en/function.isset.php
Recommended Posts:
- Difference between isset() and array_key_exists() Function in PHP
- Why to check both isset() and !empty() function in PHP ?
- PHP | IntlCalendar isSet() Function
- Node.js | util.types.isSet() Method
- Undescore.js _.isSet() with Examples
- Lodash _.isSet() Method
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
- PHP | GmagickPixel setcolor() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

