php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44149 something wrong in overload
Submitted: 2008-02-18 12:22 UTC Modified: 2008-02-19 09:16 UTC
From: edwardpro dot zhu at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.5 OS: RHEL 5
Private report: No CVE-ID: None
 [2008-02-18 12:22 UTC] edwardpro dot zhu at gmail dot com
Description:
------------
when extends father class,which declared one contruction function with params, then you extend this class and declare one another contruction function in it(not same the params list as his father class). Run it, you will find something unexcepted output. You can check the code belowed.




Reproduce code:
---------------
abstract class father{
    function father($a){
        echo "class father";
    }
}

class child extends father{
    function child(){
        echo "test";
    }
}

//run
$obj = new child('a');

Expected result:
----------------
no error,no output.

Actual result:
--------------
return wrong message: can't redeclare contraction function!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-18 16:12 UTC] felipe@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

It works fine to me on 5.2.6.
 [2008-02-19 05:33 UTC] edwardpro dot zhu at gmail dot com
i just try php 5.2.6
the result, i get, is the same as the 5.2.5.

look my instance order: new child('a');
it's not "function child()", but php run this construction function,that's may accour something unexcepted result.
 [2008-02-19 09:16 UTC] johannes@php.net
I get "test" as output which is the expected behaviour.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 17:01:31 2024 UTC