What is the use of isset() in PHP?

isset() checks whether a variable is set and is not NULL. It returns true if the variable exists and has a value, otherwise false.

<?php
$name = "Robin";

var_dump(isset($name));
var_dump(isset($age));
?>

Output:

Tutorials Class - Output Window

bool(true)
bool(false)

It is mostly used with forms, for example isset($_POST["email"]), to avoid “undefined index” warnings. Read the full chapter PHP isset() function, and learn the difference with empty().


Learn more about the similar topics:
Tutorials
PHP Variables
PHP Data Types
PHP Constants
PHP isset() Function
PHP empty() Function
PHP is_null() Function
Exercises & Assignments
Write a program to print “Hello PHP” using variable
Write a program to print a string using echo+variable.
Write a program to print two variables in single echo
Interview Questions & Answers
How to check if a variable is empty in PHP?
Is PHP a case sensitive language?
What are the different data types in PHP?
How to define a Constant in PHP?
What is the difference between $var and $$var in PHP?
Which special characters are allowed in PHP variable names?
Can we print multiple variables in a single echo statement in PHP?