Re: php/mysql object id question..

From: Date: Wed, 14 Sep 2005 21:56:58 +0000
Subject: Re: php/mysql object id question..
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-222427@lists.php.net to get a copy of this message
bruce wrote:
in their constructor, they have the 'return false' arrggghh!!! a quick look at google, and it appears that you can't return any val from a constructor. in fact, the 'object id' that's being returned appears to simply be (as you stated) the instance of the class that was created... as opposed to a return val...
If you want to stop the object from being created for any reason (e.g. connection to database failed) and you're using PHP 5, I believe that you can throw an exception in the constructor. From http://php.net/language.oop5.basic : "An object will always be assigned when creating a new object unless the object has a constructor defined that throws an exception on error." -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/

« previous php.general (#222427) next »