O'Reilly logo

Core PHP Programming: Using PHP to Build Dynamic Web Sites by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compound Statements

Flow control primitives should be compound statements, even if they only contain 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");
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required