3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {public string $r = '';} class B extends A {public int|string $r;} (new B)->r;
Output for 8.0.1 - 8.0.22, 8.1.0 - 8.1.9
Fatal error: Type of B::$r must be string (as in class A) in /in/qjM3P on line 4
Process exited with code 255.
Output for 7.4.0 - 7.4.30
Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /in/qjM3P on line 4
Process exited with code 255.

preferences:
187.59 ms | 1395 KiB | 68 Q