abstract class in php code example

Example 1: abstract function php

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

Example 2: php abstract class constant

abstract class Hello {
    const CONSTANT_1 = 'abstract'; // Make Abstract
    const CONSTANT_2 = 'abstract'; // Make Abstract
    const CONSTANT_3 = 'Hello World'; // Normal Constant
    function __construct() {
        Enforcer::__add(__CLASS__, get_called_class());
    }
}

Example 3: PHP OOP - Abstract Classes

<?php
abstract class 
    ParentClass {
  abstract public function someMethod1();
  
    abstract public function someMethod2($name, $color);
  abstract 
    public function someMethod3() : string;
}
?>

Tags:

Misc Example