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 |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |