Considering that:
Is there a way to test whether a variable exists, no matter it's NULL or not, without using the @ operator to suppress the notice?
EDIT
Together with your first replies, I've been thinking about this and I'm getting the conclusion that inspecting get_defined_vars() is the only way to distinguish between a variable set to NULL and an unset variable. PHP seems to make little distinctions:
<?php
$exists_and_is_null = NULL;
// All these are TRUE
@var_dump(is_null($exists_and_is_null));
@var_dump(is_null($does_not_exist));
@var_dump($exists_and_is_null===NULL);
@var_dump($does_not_exist===NULL);
@var_dump(gettype($exists_and_is_null)=='NULL');
@var_dump(gettype($does_not_exist)=='NULL');
?>
$result = array_key_exists('varname', get_defined_vars());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With