#19463 [Opn]: Returning from __construct()

From: Date: Sun, 01 Jun 2003 17:35:47 +0000
Subject: #19463 [Opn]: Returning from __construct()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40828@lists.php.net to get a copy of this message
ID: 19463 Updated by: helly@php.net Reported By: scotje at wwc dot edu Status: Open Bug Type: Zend Engine 2 problem Operating System: Mandrake Linux 8.2 PHP Version: 5.0.0-dev New Comment: PHP5 doesn't support nested classes. Previous Comments: ------------------------------------------------------------------------ [2003-04-18 17:45:51] thekid at thekid dot de As nested classes are no longer supported, I guess this could be closed. thekid@friebes:~ > cat | php5 <?php class A { class B { } } ?> ^D Parse error: parse error, unexpected T_CLASS, expecting T_FUNCTION in /usr/home/thekid/- on line 2 ------------------------------------------------------------------------ [2002-09-18 09:57:34] sander@php.net Reclassified. ------------------------------------------------------------------------ [2002-09-18 01:23:51] scotje at wwc dot edu 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 this bug report at http://bugs.php.net/?id=19463&edit=1

« previous php.bugs (#40828) next »