Re: PHP - Does it ignore return val from constructors?
From: Chung Leong (chernyshevsky_at_hotmail.com)
Date: 02/26/05
- Next message: Chung Leong: "Re: Class / file architecture in PHP 4"
- Previous message: Chung Leong: "Re: Automated Form Validation?"
- In reply to: thecrow: "Re: PHP - Does it ignore return val from constructors?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 26 Feb 2005 00:12:14 -0500
"thecrow" <carltonbrown@hotmail.com> wrote in message
news:1109294863.754779.98710@g14g2000cwa.googlegroups.com...
> Thank you for the explanation.
>
> That leaves me with the problem, if I fail the constructor by setting
> $this to false, how do I get the error information without echoing it?
>
> I guess I can go search on that, but if anyone has any commonly used
> ideas I would appreciate it.
>
That was just a stupid PHP 4 trick. Don't use it. It doesn't work in PHP 5.
Constructors are meant for initializing an object. They are not supposed to
fail. The only reasonable way to handle a failure in a constructor is
through exception handling, which doesn't exist in PHP 4. As others have
suggested, put the code that could potentially fail in a separate function.
- Next message: Chung Leong: "Re: Class / file architecture in PHP 4"
- Previous message: Chung Leong: "Re: Automated Form Validation?"
- In reply to: thecrow: "Re: PHP - Does it ignore return val from constructors?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|