2.1. A Top-Down View

Every PHP script is a collection of one or more statements. Each statement instructs PHP to perform a subtask, which is part of the greater algorithm. The statement appears as a collection of names, numbers, and special symbols. At the end is either a semicolon or a block of statements inside curly braces. For clarity, you may add any number of line breaks and spaces within the statement. Any block of PHP code that does work and ends in a semicolon is a statement. Listing 2.1 shows several simple statements.

Listing 2.1. Simple statements
<?php
    //an expression statement
    2 + 3;

    //another expression statement
    print("PHP!");

    //a control statement
    if(3 > 2)
    {
        //an assignment statement
        $a = 3;
    }
?>

The first statement is the ...

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.