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; } } } $content = new Content(); $content->foo = 1;
Output for 8.2.0 - 8.2.24, 8.3.0 - 8.3.12
Deprecated: Creation of dynamic property Content::$foo is deprecated in /in/smIKL on line 4
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.30

preferences:
61.13 ms | 407 KiB | 5 Q