PHP: Fatal error: Cannot instantiate abstract class

Viewed 37101

I have an abstract database class named as:

abstract class database {
  protected $value;
}

I created another abstract class

abstract class my_database extends database {
  public function set_value($value) {
    $this->value = $value;
  }
}

When I try to use it:

$my_db = new my_database();

I get error:

Fatal error: Cannot instantiate abstract class my_database in ...

What I try to do is: The abstract class database has a protected $value and I would like to create a wrapper class, to be able to change the protected value (temporarily).

How can I do that?

EDIT1: unfortunately earlier, when I tried without abstract my_database, I got the errors:

- abstract methods and must therefore be declared abstract or implemented
- Abstract function cannot contain body

EDIT2: After taking out the abstract word completely from my_database, I got the following error:

Fatal error: Class my_database contains 32 abstract methods and must therefore be declared abstract or implement the remaining methods

How can I fix this?

2 Answers
Related