Possible Duplicate:
php function overloading
I want to redeclare function such like this:
class Name{
function a(){ something; }
function a($param1){ something; }
}
but it returns
Fatal error: Cannot redeclare Name::a()
In java it just works. How can I do this in PHP?
Use default parameters:
If no parameter is passed to
Name::a()it will assign a $param1 has a value ofnull. So basically passing that parameter becomes optional. If you need to know if it has a value or not you can do a simple check: