if (true) { echo 'true'."\n";} else false : { echo 'false'."\n";}
outputs true fasle
false : { echo 'false'."\n";} Replace with label : { echo 'false'."\n";} or abc : { echo 'false'."\n";} or something They all have the same result
The identifier colon code block is part of the goto statement. If goto is not used, you can just treat it as if it is executed sequentially
Can you understand this?
if (true) {
echo 'true'."\n";
} else false : { //There is a typo here, it should be a semicolon, Why is it a colon?
echo 'false'."\n";
}
if..else... The judgment statement is true, so the first sentence will be output true, else will not be executed
The last false is a separate statement block, which will definitely be output, so the final result is
true
false
false : { echo 'false'."\n";} Replace with label : { echo 'false'."\n";} or abc : { echo 'false'."\n";} or something They all have the same result
The identifier colon code block is part of the goto statement. If goto is not used, you can just treat it as if it is executed sequentially
Can you understand this?
if (true) {
echo 'true'."\n";
} else false : { //There is a typo here, it should be a semicolon, Why is it a colon?
echo 'false'."\n";
}
if..else... The judgment statement is true, so the first sentence will be output true, else will not be executed
The last false is a separate statement block, which will definitely be output, so the final result is
true
false