Czy w PHP przeciążenie konstruktora klasy na ilość przekazanych elementów jest możliwe?
np:
class Test{
private $txt;
function __construct($a, $b)
{
$this->txt=$a." ".$b;
}
function __construct($a)
{
$this->txt=$a;
}
function go()
{echo $this->txt;}
}
$o = new Test("To jest","test");
$o->go(); //spodziewane: To jest test
$o2 = new Test("Test");
$o2->go(); //spodziewane: Test
Efekt: Fatal error: Cannot redeclare Test::__construct() in C:\AppServ\www\aplint\index.php on line 158
istnieje może jakieś magiczne słówko? ;p