php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15114 Constructor Rule, defined for PHP4 does not work in PHP4.1.1
Submitted: 2002-01-19 11:24 UTC Modified: 2002-03-23 16:34 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: arash at yalpani dot de Assigned:
Status: Closed Package: Class/Object related
PHP Version: 4.1.1 OS: Suse Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: arash at yalpani dot de
New email:
PHP Version: OS:

 

 [2002-01-19 11:24 UTC] arash at yalpani dot 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-26 00:19 UTC] webmaster at lxtype dot 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-26 07:04 UTC] arash at yalpani dot 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-03-23 16:34 UTC] arash at yalpani dot de
Ok, I found out what the Problem was: I used PHP Accelerator and somehow Problems arose. After deactivating it, everything worked just fine.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 12:01:30 2024 UTC