note 79428 deleted from language.types.null by danbrown
| From: | danbrown@php.net | Date: | Tue, 19 May 2009 14:18:10 +0000 |
| Subject: | note 79428 deleted from language.types.null by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155733@lists.php.net to get a copy of this message | ||
Note Submitter: alexey at gmail dot com
----
jaumesb aat consert doot net mentions that certain values such as empty strings or 0 convert to NULL
if compared using ==. However, objects also evaluate to NULL if they have no variable members:
<?php
class js_incomplete_object {
function js_incomplete_object() {
}
}
$tmp=new js_incomplete_object();
if ($tmp==null) {
echo "null\n";
} else {
echo "not NULL\n";
}
?>
The answer is NULL. However, if you add $this->a=1; to the constructor then the answer is not
NULL.