Will isset() return false if I assign NULL to a va

2019-03-25 05:18发布

I mean... I "set" it to NULL. So isset($somethingNULL) == true?

标签: php null isset
2条回答
混吃等死
2楼-- · 2019-03-25 05:47

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
查看更多
Rolldiameter
3楼-- · 2019-03-25 06:00
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.

From the manual. Examples on the same page.

查看更多
登录 后发表回答