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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
16 + 37 = ?
Subscribe to this entry?

 
 [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: Thu Dec 12 23:01:36 2024 UTC