3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait PersonPL{ public function sayHello($name){ echo 'Witaj, nazywam siÄ™ '.$name; } public function whereFrom($country){ echo 'Jestem z '.$country; } } trait PersonENG{ public function sayHello($name){ echo 'Hi, my name is '.$name; } public function whereFrom($country){ echo 'I am form '.$country; } } class TestA{ use PersonPL, PersonENG{ PersonPL::sayHello insteadof PersonENG; PersonENG::sayHello insteadof PersonPL; PersonPL::whereFrom insteadof PersonENG; } } $objA = new TestA(); $objA->sayHello('Anna'); $objA->whereFrom('Polski');
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined method TestA::sayHello() in /in/KtBk0:35 Stack trace: #0 {main} thrown in /in/KtBk0 on line 35
Process exited with code 255.
Output for 5.4.11 - 5.6.28
Fatal error: Call to undefined method TestA::sayHello() in /in/KtBk0 on line 35
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/KtBk0 on line 3
Process exited with code 255.