|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #9253 Class constructors can't return values
Submitted: 2001-02-14 05:23 UTC Modified: 2001-02-14 09:44 UTC
From: stefan dot p at noos dot fr Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.4pl1 OS: All
Private report: No CVE-ID: None
 [2001-02-14 05:23 UTC] stefan dot p at noos dot fr
Class constructors can't abort instance creation, for example by returning false...
This leads to a lot of "if (! $newobj->status)" crap.
Why is that ? I found a message on the PHP3 mailing list about this, but it's still not there.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-14 09:44 UTC]
class constructors are never supposed to return anything,
they are simple the fist method called after an object has 

anyway if you *really* want to return false just kill the
object itself from within the constructor  (to be sure take
the last line)


PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 14 18:01:32 2024 UTC