note 12284 deleted from language.oop by victor
| From: | victor@php.net | Date: | Sat, 07 Dec 2002 15:49:54 +0000 |
| Subject: | note 12284 deleted from language.oop by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40484@lists.php.net to get a copy of this message | ||
In php objects are stored as associative arrays.
Empty arrays are false by definition (most likely from PHP's perl heritage).
I believe what you are looking for is:
$var = new Cart();
if(!isset( $var )) echo "failure";
This is a very handy feature for writing hard to read code (i.e. job security).
But seriously, it is useful for distinguishing null from zero, or in this case:
the object was not created succesfully ( isset($var) returns false, the null case)
-from-
the object was created but not successfully initialized ( isset($var) returns true but $var is
false, the zero case)