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
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: suneelbadola at yahoo dot com
New email:
PHP Version: OS:

 

 [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 10:01:29 2025 UTC