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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 09:01:34 2024 UTC