Is there a possibility to use two functions with the same name but different parameters in PHP? Something like this:
function test()
{
echo "function test() <br />";
}
function test($abc)
{
echo "function test($abc) <br />";
}
test();
test("abc");
I know that the code above does not work, it returns the message Fatal error: Cannot redeclare test() (previously declared in C:\php\akvarium\html\test\test1.php:12). I tried to put it in a class instead, but it doesn't work either. Is there another way to solve this problem? I am currently using PHP 4, but am thinking of upgrading to PHP 5 anyway.
Edit: It is possible to do like this:
function test($abc)
{
echo "function test($abc) <br />";
}
test();
test("abc");
But if I do that I get an ugly error message: Warning: Missing argument 1 for test(). But some built-in functions can take different arguments, for example [man]echo[/man].