3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class Foo { private $data = []; public function __set($name, $value) { $this->$name = $value; } public function __isset($name) { return isset($this->$name); } public function __unset($name) { unset($this->$name); } public function __get($name) { return $this->$name; } } $foo = new Foo(); $foo->__set('uno', 'one'); $foo->__set([1], 'two'); var_dump( $foo->uno, $foo->__get([1]) );
Output for 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Deprecated: Creation of dynamic property Foo::$uno is deprecated in /in/Og25S on line 9 Warning: Array to string conversion in /in/Og25S on line 9 Deprecated: Creation of dynamic property Foo::$Array is deprecated in /in/Og25S on line 9 Warning: Array to string conversion in /in/Og25S on line 24 string(3) "one" string(3) "two"
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34
Warning: Array to string conversion in /in/Og25S on line 9 Warning: Array to string conversion in /in/Og25S on line 24 string(3) "one" string(3) "two"
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Array to string conversion in /in/Og25S on line 9 Notice: Array to string conversion in /in/Og25S on line 24 string(3) "one" string(3) "two"
Output for 7.3.32, 7.4.26
string(3) "one" string(3) "two"

preferences:
80.53 ms | 1520 KiB | 4 Q