3v4l.org

run code in 300+ PHP versions simultaneously
<?php $var; function connectToDB($string) { return false; } switch (false) { // check if we have DB credentials. case isset($DBcredentials): $DBcredentials = 'myawesomepassword';; echo "Setting var" . PHP_EOL; // connect to DB. case connectToDB($DBcredentials): // delberiate fall through, case $var is *not* caught, but we end here anyways. $var = 1; echo "Truthing Var" . PHP_EOL; case is_string($var): // delebirate fall through, case is_string($var) is *not* caught, but we end here anyways. $var = (string) $var; echo "Stringing var" . PHP_EOL; break; /* case customGuardFunction() */ default: echo "All checks passed!"; } var_dump($var);
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Setting var Truthing Var Stringing var string(1) "1"

preferences:
130.61 ms | 404 KiB | 189 Q