php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22675 Bug? Feature? Classes and Contructors
Submitted: 2003-03-13 08:34 UTC Modified: 2003-03-13 09:00 UTC
From: d dot freise at gmx dot de Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.1 OS: SuSE Linux 8.1/i386
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: d dot freise at gmx dot de
New email:
PHP Version: OS:

 

 [2003-03-13 08:34 UTC] d dot freise at gmx dot de
Hi!

I'm not a 100% certain if this is a bug, but it made me think of it...

Here is some sample code:

---

class A {
   var $test;
   function A() { $this->test = 1; }
}
class B extends A {
   function B() {}
   function out() { echo $this->test; }
}

$test = &new B;
$test->out();

---

The abose sample will output "" - an empty string. I found out that the contructor of class A is never called. I'm programing a lot with C++ and find this behaviour odd. All contructors of derived classes should be called.

I searched the bug database and found bug #1856 - rather old - telling me that it should be fixed in CVS that times.

If this an intended behaviour, please excuse me for disturbing ;-)

Dennis Freise

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-13 09:00 UTC] mgf@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is documented at http://www.php.net/manual/en/language.oop.constructor.php -- see the \"Caution\" box near the bottom.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 11:01:32 2025 UTC