Why must child method has same parameters as parent method?
overriding, php
Solution
This is because PHP does method overriding not method overloading. So method signatures must match exactly.
As a work arround for your issue you can restructure delete on your base class to
public function delete($id = null){
// Something like this (id is setted in constructor)
if ($id === null) $id = $this->id;
$this->db->delete($id);
}
Then change your subclasses method signature to match.
Problem
I have this code: ``` abstract class Base{ public function delete(){ // Something like this (id is setted in constructor) $this->db->delete($this->id); } } ``` Then i Have another class which extends Base, for instance: ``` class Subtitles extends Base{ public function delete($parameter){ parent::delete(); // Do some more deleting in transaction using $parameter } } ``` which also happens to have method delete. Here comes the problem: When i call ``` $subtitles->delete($parameter) ``` I get the: ``` Strict error - Declaration of Subtitles::delete() should be compatible with Base::delete() ``` So my question is, why i can't have the method of descendant with different parameters? Thank you for explaining.