3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A{ function a(){ $this->c = 4; function b() { $this->c += 4; } function c(){ echo $this->c; } b(); c(); } } $o = new A(); $o->a();
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/ZIDAC on line 3 Fatal error: Uncaught Error: Using $this when not in object context in /in/ZIDAC:9 Stack trace: #0 /in/ZIDAC(16): b() #1 /in/ZIDAC(23): A->a() #2 {main} thrown in /in/ZIDAC on line 9
Process exited with code 255.
Output for 5.3.18 - 5.6.28
Fatal error: Using $this when not in object context in /in/ZIDAC on line 9
Process exited with code 255.