php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8965 Superclass constructor not invoked when subclass also contains a constructor
Submitted: 2001-01-28 06:25 UTC Modified: 2001-02-22 10:50 UTC
From: jeff at iomojo dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 4.0.4pl1 OS: RedHat 7.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jeff at iomojo dot com
New email:
PHP Version: OS:

 

 [2001-01-28 06:25 UTC] jeff at iomojo dot com
If we have 2 classes:

class A {
...
  // constructor
  function A() {
    // do things
  }
...
}

class B extends A {
...
  // constructor
  function B() {
    // do things
  }
...
}

When a B object is first created, its constructor is called but the constructor for class A is not.  For things to work as expected, the constructor for class A must be called as with class C below.

class C extends A {
...
  // constructor
  function C() {
    // do things
    // Manually exec the constructor for class A
    $this->A();
  }
...
}

Not that it should matter, but my configure command is below:

'./configure' '--with-apxs=/usr/sbin/apxs' '--enable-track-vars' '--enable-magic-quotes' '--enable-sigchild' '--enable-calendar' '--enable-ftp' '--with-gd=shared' '--with-mysql=/usr/local' '--with-pdflib=shared' '--enable-wddx' '--enable-sysvmem' '--enable-sysvshm' '--with-xml' '--with-zlib' '--with-ttf' '--enable-sockets'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-22 10:50 UTC] stas@php.net
This is by design. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 13 23:01:26 2024 UTC