note 83252 deleted from language.oop5.decon by cmb
| From: | cmb@php.net | Date: | Sun, 08 Sep 2019 10:27:39 +0000 |
| Subject: | note 83252 deleted from language.oop5.decon by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212141@lists.php.net to get a copy of this message | ||
Note Submitter: KK
----
I ran into an interesting (and subtle) code error while porting some code to PHP 5.2.5 from PHP
4.4.8 that I think illustrates a noteworthy semantic.
I have a hierarchy of classes with both styles of constructors but where one in the middle was
missing the __construct() function (it just had the old-style one that called the (nonexistent)
__construct()). It worked fine in PHP4 but caused an endless loop (and stack overflow) in PHP5. I
believe what happened is that in PHP4 the old-style constructor was not called, but in PHP5 it was
(due to the "emulation" of PHP4), and since _construct() wasn't defined for that
class, the call to $this->__construct() caused a looping call to the original (lowest child)
constructor.