Posted by Andy on 12/07/05 11:57
It's true that PHP4 requires a constructor to have the same name as the
class, but that doesn't mean you have to upgrade to PHP5 just to use
the __construct method. Simply add a new method to you class with the
same name as the class and use that to call the __construct method.
Something like this should work:
class MyClass
{
function __construct($foo, $bar)
{
echo $foo, $bar;
}
function MyClass()
{
$args = func_get_args();
call_user_func_array(array(&$this, '__construct'), $args);
}
}
Andy
[Back to original message]
|