php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36075 php4.4.1 constructors are called twice
Submitted: 2006-01-19 01:35 UTC Modified: 2006-01-19 01:59 UTC
From: koukine at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.4.2 OS: Windows XP Pro SP2
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: koukine at gmail dot com
New email:
PHP Version: OS:

 

 [2006-01-19 01:35 UTC] koukine at gmail dot com
Description:
------------
1. Parent constructor should be called first
2. This class consutructor shold be called once

Reproduce code:
---------------
<?
class A{
function A(){
print("AAA; ");
}
}

class B extends A{
function B(){
print("BBB; ");
}
}

$b = &new B();
?>




Expected result:
----------------
AAA;BBB

Actual result:
--------------
BBB; AAA; BBB;

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-19 01:45 UTC] tony2001@php.net
PHP doesn't call parent constructors at all (and this is expected).
Did you actually run this code?
It produces only "BBB; ".
 [2006-01-19 01:59 UTC] koukine at gmail dot com
Yes, I did but unfortunatly I did not isolate as much as the one I posted. It is the other code of our application which was actually going through the all objects and instantiating them.

Extreamly sorry and THANKS A LOT. It was helpful.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 09:01:34 2025 UTC