3v4l.org

run code in 300+ PHP versions simultaneously
<?php function assign_foo($instance) { $instance->foo = 2; } final class Content { protected $data; public function __get(string $name) { return $this->data[$name]; } public function __set(string $name, mixed $value): void { if ($value === 1) { assign_foo($this); } else { $this->data[$name] = $value; } } } set_error_handler(function () { echo (new Exception)->getTraceAsString(); }); $content = new Content(); $content->foo = 1;

preferences:
23.33 ms | 404 KiB | 5 Q