#19463 [NEW]: Returning from __construct()

From: Date: Wed, 18 Sep 2002 06:23:51 +0000
Subject: #19463 [NEW]: Returning from __construct()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-19602@lists.php.net to get a copy of this message
From: scotje@wwc.edu Operating system: Mandrake Linux 8.2 PHP version: 4CVS-2002-09-18 PHP Bug Type: Class/Object related Bug description: Returning from __construct() The version is actually the 4.3.0 zend2 alpha2. I'm wondering if it is possible to return an instance of a subclass from a constructor. For example: class test1 { class test2 { function prt_test() { echo("testing!!!"); } } function __construct() { return new test2(); } } $test_obj = new test1(); $test_obj->prt_test(); ?> Let's say that I want to parent class to choose one of it's children to actually provide the functionality based on some selection criteria. This isn't a big issue since I can just use a function seperate from the constructor to accompolish roughly the same thing. I'm just wondering if this is something that was considered or encountered already. Thanks... -- Edit bug report at http://bugs.php.net/?id=19463&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=19463&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=19463&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=19463&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=19463&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=19463&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=19463&r=support Expected behavior: http://bugs.php.net/fix.php?id=19463&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=19463&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=19463&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=19463&r=globals

« previous php.bugs (#19602) next »