mirror of
https://github.com/php/php-src.git
synced 2024-09-24 11:27:28 +00:00
b501570ab0
#Getting accustomed to the infrastructure. #Any comments are welcome, especially with regard to syntax and keywords.
31 lines
526 B
PHP
31 lines
526 B
PHP
--TEST--
|
|
Express requirements of a trait by abstract methods.
|
|
--FILE--
|
|
<?php
|
|
error_reporting(E_ALL);
|
|
|
|
trait Hello {
|
|
public function sayHelloWorld() {
|
|
echo 'Hello'.$this->getWorld();
|
|
}
|
|
abstract public function getWorld();
|
|
}
|
|
|
|
class MyHelloWorld {
|
|
private $world;
|
|
use Hello;
|
|
public function getWorld() {
|
|
return $this->world;
|
|
}
|
|
public function setWorld($val) {
|
|
$this->world = $val;
|
|
}
|
|
}
|
|
|
|
$o = new MyHelloWorld();
|
|
$o->setWorld(' World!');
|
|
$o->sayHelloWorld();
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Hello World!
|