3v4l.org

run code in 500+ PHP versions simultaneously
<?php class X { static public $p = 1; static function foo() {} function __toString() : string { return 'foo'; } } $name = []; // try with different type : bool, int, float, object.. try { echo X::$name; } catch (Error $e) { print $e->getMessage(); } $name = []; try { echo X::${$name}(); } catch (Error $e) { print $e->getMessage(); } ?>
Output for 8.1.32 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.6
Access to undeclared static property X::$name Warning: Array to string conversion in /in/aKlmO on line 22 Warning: Undefined variable $Array in /in/aKlmO on line 22 Method name must be a string

preferences:
50.93 ms | 867 KiB | 4 Q