I mean... I "set" it to NULL. So isset($somethingNULL) == true?
I mean... I "set" it to NULL. So isset($somethingNULL) == true?
bool isset ( mixed $var [, mixed $var [, $... ]] )
Determine if a variable is set and is not NULL.
If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL. Also note that a NULL byte ("\0") is not equivalent to the PHP NULL constant.
Return values
Returns TRUE if var exists and has value other than NULL, FALSE otherwise.
Yes - from the ISSET() documentation:
$foo = NULL;
var_dump(isset($foo)); // FALSE
/* Array example */
$a = array ('test' => 1, 'hello' => NULL);
var_dump(isset($a['test'])); // TRUE
var_dump(isset($a['foo'])); // FALSE
var_dump(isset($a['hello'])); // FALSE
If you need to check if an array contains a key but its value is null, you can use array_key_exists
<?php
$array = [
'qwe' => null,
'foo' => 123,
];
var_dump(isset($array['foo'])); // bool(true)
var_dump(array_key_exists('foo', $array)); // bool(true)
var_dump(isset($array['qwe'])); // bool(false)
var_dump(array_key_exists('qwe', $array)); // bool(true) <---
var_dump(isset($array['bar'])); // bool(false)
var_dump(array_key_exists('bar', $array)); // bool(false)