Die(a) is the same as
print(a);
exit;
ie: it sends the argument to the output and then ends the script execution
code:
switch($random)
{
case 1:
echo 'I knew it was gonna be 1';
case 2:
echo 'Who\'d say it was gonna be 2';
default:
echo 'I couldn\'t guess it';
}
If $random is 1, This switch runs from case 1 and also runs case 2 and default since nothing stops the interpreter.
code:
switch($random)
{
case 1:
echo 'I knew it was gonna be 1';
break;
case 2:
echo 'Who\'d say it was gonna be 2';
break;
default:
echo 'I couldn\'t guess it';
break;
}
In this case only case 1 is run and then the switch is exited by break
code:
switch($random)
{
default:
echo 'I couldn\'t guess it';
break;
case 1:
echo 'I knew it was gonna be 1';
break;
case 2:
echo 'Who\'d say it was gonna be 2';
break;
}
Even in this case, default will only be run if $random is neither 1 nor 2. You have to mind the break's the rest is just as it's supposed to work.