W3Schools.com (2024)

❮ PHP Variable Handling Reference

Example

Check whether a variable is empty. Also check whether the variable is set/declared:

<?php
$a = 0;
// True because $a is set
if (isset($a)) {
echo "Variable 'a' is set.<br>";
}

$b = null;
// False because $b is NULL
if (isset($b)) {
echo "Variable 'b' is set.";
}
?>

Try it Yourself »

Definition and Usage

The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL.

This function returns true if the variable exists and is not NULL, otherwise it returns false.

Note: If multiple variables are supplied, then this function will return true only if all of the variables are set.

Tip: A variable can be unset with the unset() function.

Syntax

Parameter Values

Parameter Description
variable Required. Specifies the variable to check
... Optional. Another variable to check

Technical Details

Return Value: TRUE if variable exists and is not NULL, FALSE otherwise
Return Type: Boolean
PHP Version: 4.0+
PHP Changelog: PHP 5.4: Non-numeric offsets of strings now returns FALSE

❮ PHP Variable Handling Reference

W3schools Pathfinder

Track your progress - it's free!

W3Schools.com (2024)
Top Articles
Latest Posts
Article information

Author: Aron Pacocha

Last Updated:

Views: 6558

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Aron Pacocha

Birthday: 1999-08-12

Address: 3808 Moen Corner, Gorczanyport, FL 67364-2074

Phone: +393457723392

Job: Retail Consultant

Hobby: Jewelry making, Cooking, Gaming, Reading, Juggling, Cabaret, Origami

Introduction: My name is Aron Pacocha, I am a happy, tasty, innocent, proud, talented, courageous, magnificent person who loves writing and wants to share my knowledge and understanding with you.