Reputation: 905
I have two interfaces with same method names. But, both the methods have different signatures. As per my information two interfaces with same method names and same signature will not work. But, in this case signature ( that is number of arguments) are different. Then why program is not working ?
<?php
interface Car {
public function setModel($name);
}
interface Vehicle {
public function setModel();
}
class miniCar implements Car, Vehicle {
private $model;
public function setModel($name)
{
$this -> model = $name;
}
public function setModel()
{
echo 'do nothing';
}
}
$obj = new miniCar();
?>
Upvotes: 1
Views: 1422
Reputation: 344
PHP functions cannot be overloaded. They must have different names.
Upvotes: 2