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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC