Skip to content

Instantly share code, notes, and snippets.

@clarkgrubb
Created August 19, 2011 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save clarkgrubb/1157508 to your computer and use it in GitHub Desktop.
Save clarkgrubb/1157508 to your computer and use it in GitHub Desktop.
isset is the logical negation of is_null
$ uname -v
Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386
$ php --version
PHP 5.3.4 (cli) (built: Dec 15 2010 12:15:07)
$ php -a
Interactive mode enabled
<?
$null = NULL;
if ( is_null($null) ) {
echo "null is NULL\n";
}
if ( ! isset($null) ) {
echo "null is not set\n";
}
if ( is_null($not_set) ) {
echo "not_set is NULL\n";
}
if ( ! isset($also_not_set) ) {
echo "also_not_set is not set\n";
}
?>
null is NULL
null is not set
not_set is NULL
also_not_set is not set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment