CKTIS / PHP
isset: present and not null
isset checks whether a variable or selected element exists and has a value other than null. It does not distinguish a missing key from a key containing null.
Version: PHP 8.4
Syntax
isset($var, ...$vars): boolisset($value) is false for an undefined variable and for null. It is true for 0, false and an empty string. It is therefore not a test of truthiness, nonemptiness or data validity.
For an array, isset($data["nickname"]) also checks a missing key without a warning. To distinguish an absent key from an explicitly stored null value, use array_key_exists. In the example, the nickname key exists but contains null.
With several arguments, all must exist and differ from null. Checking stops at the first unsatisfied condition. isset is a language construct: it takes variables rather than arbitrary expressions and does not support named arguments.
A true result does not confirm type, permissions or content safety. On objects, checking an inaccessible property can call __isset if that method is defined. Do not assume that every such check is merely a simple field read.
Examples
<?php
declare(strict_types=1);
$data = ["nickname" => null, "score" => 0, "active" => false];
var_export(isset($data["nickname"])); echo "\n";
var_export(array_key_exists("nickname", $data)); echo "\n";
var_export(isset($data["score"], $data["active"])); echo "\n";
var_export(isset($data["missing"])); echo "\n";
Result
false true true false