3v4l.org

run code in 300+ PHP versions simultaneously
<?php function f(string $str): void { if ($a = explode("-", $str)) { echo "reached if: ", var_dump($a), "\n"; } else { echo "unreached else\n"; } } f(""); f("a"); f("a-b-c");
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.26, 8.1.0 - 8.1.13, 8.2rc1 - rc3
reached if: array(1) { [0]=> string(0) "" } reached if: array(1) { [0]=> string(1) "a" } reached if: array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" }

preferences:
18.01 ms | 410 KiB | 5 Q