G.3. Compound Statements

Flow-control primitives should be compound statements, even if they contain only one instruction. Like functions, compound statements should have opening braces that start at column zero relative to scope. Code within the braces forms a new scope and should be indented.

// tell the user if a is equal to ten
if($a==10)
{
    printf("a is ten.\n");
}
else
{
    printf("a is not ten.\n");
}

Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.