Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php trait

<?php
class Base {
    public function sayHello() {
        echo 'Hello ';
    }
}

trait SayWorld {
    public function sayHello() {
        parent::sayHello();
        echo 'World!';
    }
}

class MyHelloWorld extends Base {
    use SayWorld;
}

$o = new MyHelloWorld();
$o->sayHello();
?>
Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #php #trait
ADD COMMENT
Topic
Name
4+4 =