I'm learning advanced level of OOP PHP..(Or I want to learn :))
This is my code.
Excerpt:
<?php
abstract class Karakter
{
abstract public function isim($name);
abstract public function yas($age);
public function yazdir()
{
print $this->isim() . " " . $this->yas();
}
}
class Insan extends Karakter
{
public $isim;
public $yas;
public function isim()
{
return "Bu adamın ismi: " . $this->isim;
}
public function yas()
{
return "Bu adamın yaşı: " . $this->yas;
}
}
When I run this code I can't win through. I can see this error:
Fatal error: Declaration of Insan::isim() must be compatible with that of Karakter::isim() in C:\AppServ\www\OOP\1.php on line 26
You have defined the function isim in the abstract class with one parameter.
abstract public function isim($name);
In order to correctly implement this function in any subclass you must override the function with exactly one parameter:
class Insan extends Karakter {
public function isim($name) {
[..]
}
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With