3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait MyTrait { private $abc = 1; public static function increment($by) { $this->abc += $by; } public function getValue() { return $this->abc; } } class MyClass { use MyTrait; public function increment() { MyTrait::increment(1); } } $c = new MyClass; $c->increment(); $c->increment(); var_dump($c->getValue());
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Calling static trait method MyTrait::increment is deprecated, it should only be called on a class using the trait in /in/ptmU9 on line 23 Fatal error: Uncaught Error: Using $this when not in object context in /in/ptmU9:8 Stack trace: #0 /in/ptmU9(23): MyTrait::increment(1) #1 /in/ptmU9(28): MyClass->increment() #2 {main} thrown in /in/ptmU9 on line 8
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:
50.87 ms | 401 KiB | 8 Q