3v4l.org

run code in 300+ PHP versions simultaneously
<?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; public function sayHello($name){ parent::sayHello($name); TraitMethod::sayHello($name); } } $objTestC = new TestC(); $objTestC->sayHello("Anna");
Output for git.master, git.master_jit, rfc.property-hooks
Hello world! I am Anna Deprecated: Calling static trait method TraitMethod::sayHello is deprecated, it should only be called on a class using the trait in /in/KPVBC on line 20 Fatal error: Uncaught Error: Non-static method TraitMethod::sayHello() cannot be called statically in /in/KPVBC:20 Stack trace: #0 /in/KPVBC(25): TestC->sayHello('Anna') #1 {main} thrown in /in/KPVBC on line 20
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.53 ms | 401 KiB | 8 Q