- Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.22
- Fatal error: Abstract function AbstractClass::__construct() cannot contain body in /in/ETKe6 on line 6
Process exited with code 255.
<?php
abstract class AbstractClass
{
abstract function __construct() {
echo 'aaa';
}
// Our abstract method only needs to define the required arguments
abstract protected function prefixName($name);
}
class ConcreteClass extends AbstractClass
{
public function __construct($a) {
echo $a;
}
// Our child class may define optional arguments not in the parent's signature
public function prefixName($name, $separator=0 ) {
if ($name == "Pacman") {
$prefix = "Mr";
} elseif ($name == "Pacwoman") {
$prefix = "Mrs";
} else {
$prefix = "";
}
return "{$prefix}{$separator} {$name}";
}
}
$class = new ConcreteClass(666699990000);
echo $class->prefixName("Pacman"), "\n";
echo $class->prefixName("Pacwoman"), "\n";
?>