Blocks are lexical structures where multiple statements are grouped together. Similar to C/C++ and Java, blocks are defined with braces { ... }.
Following rules apply:
echo( One ); // Single statement
{
echo( Two ); // Multiple statements inside a block
echo( Three );
{ // Nested blocks
echo( Four );
{ } // Empty blocks are tolerated
{ {} }
{ ; ;; };; // Redundant semicolons are tolerated
}
if (true) // If statement
{
echo ( Five ); echo ( Six );
}
else:
{
echo( Six and half not shown );
}
{ // This block lies outside the if-statement
echo( Seven );
}
}
One
Two
Three
Four
Five
Six
Seven