Interrupting instantiation
| From: | Chris Boget | Date: | Thu, 07 Oct 2004 16:59:25 +0000 |
| Subject: | Interrupting instantiation | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-198860@lists.php.net to get a copy of this message | ||
In PHP4, is there any way to interrupt instantiation of an
object? For example, by returning NULL as the return
value of the class constructor so that the variable you are
assinging the object to is, instead, null?
Here's what I'm trying to do:
class MyClass {
function MyClass() {
return NULL;
}
}
$myVar = new MyClass();
echo 'IsObject? [' . is_object( $myVar ) . ']<br>';
I would expect $myVar to be a NULL value. Or at least,
not an object of MyClass. But it is an object of MyClass.
So is there any way to interrupt the instantiation? So that,
if there is an error during the execution of the constructor,
an object isn't returned?
thnx,
Chris