php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38529 cunstructor overloading is not allowed in php5
Submitted: 2006-08-21 04:18 UTC Modified: 2006-08-21 08:41 UTC
From: suneelbadola at yahoo dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.1.5 OS: Linux/Windows
Private report: No CVE-ID: None
 [2006-08-21 04:18 UTC] suneelbadola at yahoo dot com
Description:
------------
The constructor over loading is not allowed in PHP however for being OOPS based language it should.

Reproduce code:
---------------
class PDF extends FPDF
{

public function __construct($one){
	echo "one";
}
public function __construct($one,$two){
	echo "two";
}
public function __construct(){
    echo "blank";
}
}

Expected result:
----------------
it should allow us contructor overloading.

Actual result:
--------------
error: can not redeclare function.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-21 08:41 UTC] tony2001@php.net
Function overloading is not supported and never going to be, since PHP is weakly typed language.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 21:01:33 2025 UTC