. . .

constructor overloading

May 12, 2011

Constructor Overloading in PHP

There is no simple method of overloading constructors in PHP. There are few workarounds to achieve this. I use the following technique. class UserIdentity extends CUserIdentity { public function __construct() { $arg_list = func_get_args(); switch(func_num_args()) { case 1: // calling from admin end.... $this->_user = $arg_list[0];; parent::__construct($this->_user->username,$this->_user->password); break; case 2: […]