PHP null var存在[重复]

Possible Duplicate:
Check if value isset and null

If I have $v = NULL; how can I check that $v is exists and it's NULL?

isset($v) => false //because of NULL, but $v exists

You can’t, null is equivalent to a non-existing variable:

A variable is considered to be null if:

  • it has been assigned the constant NULL.
  • it has not been set to any value yet.
  • it has been unset().

Only for arrays you can check whether a key exists although its value is null using array_key_exists.

If you would like to put it all together to test existence and a null value

<?php
if(!is_null($v)){
// do something
}
?>

You should be careful using isset on variables that can be null. It's a good way to set yourself up for bugs and problems in the future.

What you could do for now is to use is_null as an additional test.