note 79428 added to language.types.null
| From: | alexey at gmail dot com | Date: | Tue, 27 Nov 2007 07:26:41 +0000 |
| Subject: | note 79428 added to language.types.null | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132587@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.197
Probable Submitter: 79.126.32.216
----
Manual Page -- http://www.php.net/manual/en/language.types.null.php
Edit -- https://master.php.net/note/edit/79428
Del: integrated -- https://master.php.net/note/delete/79428/integrated
Del: useless -- https://master.php.net/note/delete/79428/useless
Del: bad code -- https://master.php.net/note/delete/79428/bad+code
Del: spam -- https://master.php.net/note/delete/79428/spam
Del: non-english -- https://master.php.net/note/delete/79428/non-english
Del: in docs -- https://master.php.net/note/delete/79428/in+docs
Del: other reasons-- https://master.php.net/note/delete/79428
Reject -- https://master.php.net/note/reject/79428
Search -- https://master.php.net/manage/user-notes.php