Re: Q on class failure...
| From: | Curt Zirzow | Date: | Mon, 22 Sep 2003 07:55:50 +0000 |
| Subject: | Re: Q on class failure... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-163424@lists.php.net to get a copy of this message | ||
* Thus wrote jsWalter (jsWalter@torres.ws):
> I found this in the docs...
>
> If you want your constructor to possibly not create the object
>
> class A
> {
> function A()
> {
> // ...
> // some error occurred
> $this = null;
> return;
> }
> }
>
> I tested it, it works great.
>
> Then I read on...
>
> Setting $this to null isn't available in PHP 4.3.3R3 anymore. Maybe in
> version below also.
>
> Great! :/
>
> I have 4.3.2, so I guess it would work for me.
>
> If this "feature" has been removed, can someone show me a good way to
> indicate a failure on object instantiation?
The constructor should be as quick as possible and have as little
logic as possible. What kind of failure are you trying to catch?
Curt
--
"I used to think I was indecisive, but now I'm not so sure."