fork download
  1. <?php
  2.  
  3. trait HelloWorld{
  4. static $age = 'Вася';
  5. static function sayHello() {
  6. echo 'Привет ';
  7. }
  8. }
  9.  
  10. class GetInfo{
  11. use HelloWorld;
  12. public function getPiple(){
  13. echo $this->sayHello();
  14. }
  15. }
  16.  
  17. //GetInfo::sayHello(); //Привет
  18. //echo GetInfo::$age; //Вася
  19.  
  20. $a = new GetInfo();
  21. $a->getPiple();
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
Привет