3v4l.org

run code in 500+ PHP versions simultaneously
<?php class X { public static int $int = 1; public string $string = 'abc'; } function foo() { $foo = new X(); $varString = &$foo->string; $varString = []; //Cannot assign array to reference held by property X::$string of type string $varInt = &X::$int; $varInt = 'abc'; //Cannot assign string to reference held by property X::$int of type int } foo();
Output for 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
Fatal error: Uncaught TypeError: Cannot assign array to reference held by property X::$string of type string in /in/H1uAS:12 Stack trace: #0 /in/H1uAS(21): foo() #1 {main} thrown in /in/H1uAS on line 12
Process exited with code 255.

preferences:
63.58 ms | 865 KiB | 4 Q