mirror of
https://github.com/php/php-src.git
synced 2024-09-25 03:47:26 +00:00
b501570ab0
#Getting accustomed to the infrastructure. #Any comments are welcome, especially with regard to syntax and keywords.
30 lines
435 B
PHP
30 lines
435 B
PHP
--TEST--
|
|
Traits can fulfill the requirements of abstract base classes.
|
|
--FILE--
|
|
<?php
|
|
error_reporting(E_ALL);
|
|
|
|
abstract class Base {
|
|
abstract function sayWorld();
|
|
}
|
|
|
|
trait Hello {
|
|
public function sayHello() {
|
|
echo 'Hello';
|
|
}
|
|
public function sayWorld() {
|
|
echo ' World!';
|
|
}
|
|
}
|
|
|
|
class MyHelloWorld extends Base {
|
|
use Hello;
|
|
}
|
|
|
|
$o = new MyHelloWorld();
|
|
$o->sayHello();
|
|
$o->sayWorld();
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Hello World!
|