3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function test(int $X): int|string { if($X % 2 == 0) { return $X * 2; } else { return "{$X}"; } } echo test((int)"13");
Output for 8.1.23 - 8.1.27, 8.2.10 - 8.2.17, 8.3.0 - 8.3.4
13
Output for 7.0.0
Parse error: syntax error, unexpected '|', expecting '{' in /in/puIWs on line 4
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Warning: Unsupported declare 'strict_types' in /in/puIWs on line 2 Parse error: syntax error, unexpected ':', expecting '{' in /in/puIWs on line 4
Process exited with code 255.

preferences:
69.42 ms | 401 KiB | 40 Q