How to declare abstract method in non-abstract class in PHP?

See the chapter on Class Abstraction in the PHP manual:

PHP 5 introduces abstract classes and methods. Classes defined as abstract may not be instantiated, and any class that contains at least one abstract method must also be abstract. Methods defined as abstract simply declare the method’s signature – they cannot define the implementation.

It means you either have to

abstract class absclass { // mark the entire class as abstract
    abstract public function fuc();
}

or

class absclass {
    public function fuc() { // implement the method body
        // which means it won't be abstract anymore
    };
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)