3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Basic{ public function sayHello($name){ echo 'Hello world! I am '.$name; } } trait TraitMethod{ public function sayHello($name){ echo 'Hello! My name is '.$name; } } class TestC extends Basic{ use TraitMethod{ TraitMethod::sayHello as sayHelloTrait; } public function sayHello($name){ parent::sayHello($name); sayHelloTrait($name); } } $objTestC = new TestC(); $objTestC->sayHello("Anna");
based on KPVBC
Output for 7.0.0 - 7.2.0
Hello world! I am Anna Fatal error: Uncaught Error: Call to undefined function sayHelloTrait() in /in/4Yu8j:22 Stack trace: #0 /in/4Yu8j(27): TestC->sayHello('Anna') #1 {main} thrown in /in/4Yu8j on line 22
Process exited with code 255.
Output for 5.4.11 - 5.6.28
Hello world! I am Anna Fatal error: Call to undefined function sayHelloTrait() in /in/4Yu8j on line 22
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/4Yu8j on line 9
Process exited with code 255.