3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* class A { public function __set($name, $value) { echo func_get_arg(0); $name = "xxx"; echo func_get_arg(0); } public function test($name) { echo func_get_arg(0); $name = "xxx"; echo func_get_arg(0); } } $a = new A(); $a->test('test'); $a->test = 5; function byVal($arg) { echo 'As passed : ', var_export(func_get_arg(0)), PHP_EOL; $arg = 'baz'; echo 'After change : ', var_export(func_get_arg(0)), PHP_EOL; } function byRef(&$arg) { echo 'As passed : ', var_export(func_get_arg(0)), PHP_EOL; $arg = 'baz'; echo 'After change : ', var_export(func_get_arg(0)), PHP_EOL; } $arg = 'bar'; byVal($arg); byRef($arg); */ function set($name, $value) { $a = array(); echo $name; // property setter support $originalName = $name; $name[0] = $name[0] & "\xDF"; // case-sensitive checking, capitalize first character echo $name; // protected attribute support $properties = $this->listObjectProperties(); if (isset($a[$name = $originalName])) { echo $name; } echo $name; } set('user', 'test');
based on D1PrN
Output for 7.0.0 - 7.2.0
userUser Fatal error: Uncaught Error: Using $this when not in object context in /in/K1OX2:54 Stack trace: #0 /in/K1OX2(61): set('User', 'test') #1 {main} thrown in /in/K1OX2 on line 54
Process exited with code 255.
Output for 5.3.19 - 5.6.28
userUser Fatal error: Using $this when not in object context in /in/K1OX2 on line 54
Process exited with code 255.