3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait T1 { private function a1() { echo 1; } protected function a() { echo 2; } protected function a2() { echo 3; } } class A{ use T1; public static function s(){ $this->a1(); $this->a(); $this->a2(); } } A::s();
based on LIoq4
Output for 7.0.0 - 7.2.0
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in /in/KTm01 on line 14 Fatal error: Uncaught Error: Using $this when not in object context in /in/KTm01:17 Stack trace: #0 /in/KTm01(23): A::s() #1 {main} thrown in /in/KTm01 on line 17
Process exited with code 255.
Output for 5.4.10 - 5.6.28
Fatal error: Using $this when not in object context in /in/KTm01 on line 17
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/KTm01 on line 3
Process exited with code 255.