3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "Hello \n"; class foo { protected $values = array(); public function __set($key, $value) { echo "Set:$key to $value \n"; $this->$key = $value; //$this->values[$key] = $value; } public function __get($key) { echo "Get:$key \n"; //return $this->values[$key]; return $this->$key; } } $foo = new foo(); $foo->bar = 'assigning bar'; echo $foo->bar; ?>
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Hello Set:bar to assigning bar Deprecated: Creation of dynamic property foo::$bar is deprecated in /in/HqDhf on line 11 assigning bar
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 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.28
Hello Set:bar to assigning bar assigning bar

preferences:
240.48 ms | 403 KiB | 326 Q