3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class foo { private $private_bar = 'private'; protected $protected_bar = 'protected'; public $public_bar = 'public'; public static $static_bar = 'static'; private function private_echo() { echo $this->private_bar; } protected function protected_echo() { echo $this->protected_bar; } public function public_echo() { echo $this->public_bar; } public static function static_echo() { echo $this->static_bar; } } $myfoo = new foo(); $myfoo->static_echo(); $myfoo->public_echo(); $myfoo->protected_echo(); $myfoo->private_bar = 'new private bar'; $myfoo->private_echo(); $myfoo::static_echo(); ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/PpuUi:24 Stack trace: #0 /in/PpuUi(28): foo::static_echo() #1 {main} thrown in /in/PpuUi on line 24
Process exited with code 255.
Output for 5.3.0 - 5.6.28
Fatal error: Using $this when not in object context in /in/PpuUi on line 24
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /in/PpuUi on line 36
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /in/PpuUi on line 36
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/PpuUi on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/PpuUi on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/PpuUi on line 4
Process exited with code 255.