3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set("memory_limit", "5M"); class Foo { public function __set($prop, $value) { echo "__set($prop, $value)\n"; if ($value == "bar") { str_repeat("a", 1e7); } } } $foo = new Foo(); register_shutdown_function(function() use ($foo) { $foo->bar = 'baz'; }); $foo->bar = 'bar';
Output for 8.2.0 - 8.2.24, 8.3.0 - 8.3.12
__set(bar, bar) Fatal error: Allowed memory size of 5242880 bytes exhausted (tried to allocate 10000032 bytes) in /in/Q7nSo on line 9 Deprecated: Creation of dynamic property Foo::$bar is deprecated in /in/Q7nSo on line 17
Process exited with code 255.
Output for 8.1.0 - 8.1.30
__set(bar, bar) Fatal error: Allowed memory size of 5242880 bytes exhausted (tried to allocate 10000032 bytes) in /in/Q7nSo on line 9
Process exited with code 255.

preferences:
52.55 ms | 407 KiB | 5 Q