3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class Foo { public function __set(string $name, int $value): void { $this->{$name} = $value; } } try { $o = new Foo; $o->{'"foo&voilà"'} = '5'; echo implode(', ', array_keys(get_object_vars($o))); } catch (throwable $e) { echo get_class($e); }
Output for 8.1.0 - 8.1.6
TypeError
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.29, 8.0.0 - 8.0.19
"foo&voilà"

preferences:
95.97 ms | 410 KiB | 5 Q