3v4l.org

run code in 300+ PHP versions simultaneously
<?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');
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 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.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
userUser Fatal error: Using $this when not in object context in /in/K1OX2 on line 54
Process exited with code 255.

preferences:
214.03 ms | 402 KiB | 257 Q