SV: PHP Error

From: Date: Thu, 02 Mar 2000 21:44:13 +0000
Subject: SV: PHP Error
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-11395@lists.php.net to get a copy of this message
> I believe your error is caused by an overflow because baseclass > has class 1 > in it and class 1 is inherited from 0 so you get an infinite loop: > > 1 = 0 > 0 -> 1 > 1 = 0 > 0 -> 1 Looking at the backtrace it sure looks like an overflow after an infinite loop. However, I don't agree that it should be there. Look at the code again: ----------------- <?php class Base_class { function Base_class () { $this->First = new First_class(); } } class First_class extends Base_class { function First_class() { $this->Sec = new Second_class(); } } class Second_class extends Base_class { } $Obj = new First_class(); ?> ------------------ A) 1. We instantiate First_class in $Obj. 2. First_class calls its constructor which instantiantes Second_class. 3. Second_class _has_no_constructor_, so nothing more should happen!! From the PHP manual (Chap 13. Classes and objects): "For derived classes, the constructor of the parent class is not automatically called when the derived class's constructor is called." I further take it that when a class has no constructor (Second_class above), the constructor of the parent class will not be called (?!). B) Even if, for some reason unknown to me, the above code should really be considered invalid, it should still not segfault apache. Regards, /Johan Ekenberg

« previous php.version4 (#11395) next »