Is it a parser bug, or is there any usefulness in using curly brackets like this?
$x = 1;
{
$x++;
}
As far as I can see, it behaves exactly as if the brackets weren't there, so why is it valid syntax?
There is no any hidden meaning. It is more about readability.
Check manual:
Any PHP script is built out of a series of statements. A statement can be an assignment, a function call, a loop, a conditional statement or even a statement that does nothing (an empty statement). Statements usually end with a semicolon. In addition, statements can be grouped into a statement-group by encapsulating a group of statements with curly braces. A statement-group is a statement by itself as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With