#46022 [Opn->Bgs]: constructor version compatable

From: Date: Mon, 08 Sep 2008 18:56:38 +0000
Subject: #46022 [Opn->Bgs]: constructor version compatable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-128778@lists.php.net to get a copy of this message
ID: 46022 Updated by: jani@php.net Reported By: vivekanandan at classof1 dot com -Status: Open +Status: Bogus -Bug Type: *General Issues +Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.3.0alpha2 New Comment: RTFM: "For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old- style constructor function, by the name of the class." So in this case as you provide the "new" style (and proper) constructor the BC fallback is simply ignored. No bug here. Previous Comments: ------------------------------------------------------------------------ [2008-09-08 13:54:10] vivekanandan at classof1 dot com Description: ------------ when we define both constructor types as class name as construct name and __construct keyword , we need to produce error Reproduce code: --------------- class UserInfo{ function __construct(){ print "<br> __construct function is called "; } function UserInfo(){ print "UserInfo constructor is called"; } function getUserInfo(){ print "<br>This is User Defined function "; } } $obj = new UserInfo(); $obj->getUserInfo(); Expected result: ---------------- produce error : Constructor cannot be difined more than once Actual result: -------------- __construct function is called ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46022&edit=1

« previous php.bugs (#128778) next »