- defined: documentation ( source)
<?php
abstract class ParentClass {
const TEST_CONSTANT = null;
public function __construct()
{
if (!defined(self::TEST_CONSTANT)) {
throw new Exception("Please define TEST_CONSTANT!");
}
}
abstract protected function someFunction();
}
class ChildClass extends ParentClass {
const TEST_CONSTANT = "value";
protected function someFunction()
{
//some functionality here
}
}
$x = new ChildClass();