PHP isset() with multiple parameters
The isset()
function in PHP can take multiple parameters, and it will return TRUE
if all of the variables passed to it have been set, and FALSE
if any of them have not. For example:
<?php
$a = "Hello";
$b = "World";
if (isset($a, $b)) {
echo "Both variables are set.";
} else {
echo "One or both variables are not set.";
}
Watch a video course
Learn object oriented PHP
This will output "Both variables are set." because both $a and $b have been assigned values.
<?php
$a = "Hello";
$b;
if (isset($a, $b)) {
echo "Both variables are set.";
} else {
echo "One or both variables are not set.";
}
This will output "One or both variables are not set." because $b is not assigned any values.