Bug #15114 Updated: Constructor Rule, defined for PHP4 does not work in PHP4.1.1

From: Date: Sat, 23 Mar 2002 21:34:33 +0000
Subject: Bug #15114 Updated: Constructor Rule, defined for PHP4 does not work in PHP4.1.1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-3215@lists.php.net to get a copy of this message
ID: 15114 Updated by: arash@yalpani.de Reported By: arash@yalpani.de -Status: Open +Status: Closed Bug Type: Class/Object related Operating System: Suse Linux PHP Version: 4.1.1 New Comment: Ok, I found out what the Problem was: I used PHP Accelerator and somehow Problems arose. After deactivating it, everything worked just fine. Previous Comments: ------------------------------------------------------------------------ [2002-01-26 07:04:54] arash@yalpani.de Hm, strange...Maybe the error does not occur on a Windows system (I have a Linux server)!? And no: I do not include any other File. Thanks, Arash ------------------------------------------------------------------------ [2002-01-26 00:19:42] webmaster@lxtype.com I was unable to reproduce this bug. The following code executes as expected for me (Win2k/Apache PHP 4.1.1): class Bike { function Bike() { echo 'Constructor of class "Bike"<br>'; } } class MountainBike extends Bike { } $mb = new MountainBike(); class Bike2 { function Bike2() { echo 'Constructor of class "Bike2"<br>'; } } class MountainBike2 extends Bike2 { function MountainBike2() { parent::Bike2(); } } $mb = new MountainBike2(); It outputs: Constructor of class "Bike" Constructor of class "Bike2" with no compile errors. Double check that you aren't including a wrong file, etc. ------------------------------------------------------------------------ [2002-01-19 11:24:10] arash@yalpani.de In the documentation (http://www.php.net/manual/en/language.oop.constructor.php) you defined the following rule: "If a class has no constructor, the constructor of the base class is being called, if it exists" This worked in PHP 4.0.6 for me. After upgrading to Version 4.1.1, it doesn't. Here are my test-scripts. The first one ends up with no output or the errormessage: "Fatal error: Cannot instantiate non-existent class: mountainbike in /www/testOO.php on line 15". actually, the behaviour seems to be undefined. The second one works, as it should be, but only because of actively calling the constructor of the base class. FIRST: <?php class Bike { function Bike() { echo 'Constructor of class "Bike"'; } } class MountainBike extends Bike { } $mb = new MountainBike(); ?> SECOND: <?php class Bike { function Bike() { echo 'Constructor of class "Bike"'; } } class MountainBike extends Bike { function MountainBike() { parent::Bike(); } } $mb = new MountainBike(); ?> Greetings, Arash My configure line is: ./configure \ --with-apxs=/usr/local/apache/1.3.20/bin/apxs \ --enable-track-vars \ --enable-ftp \ --with-zlib \ --with-gd \ --with-pdflib \ --with-sockets \ --enable-sockets \ --with-sysvshm \ --with-sysvsem \ --enable-dbg=shared \ --with-dbg-profiler \ --with-mysql=/usr/local/mysql/current \ --with-pgsql=/usr/local/pgsql \ --with-mcrypt ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15114&edit=1

« previous php.bugs (#3215) next »