O'Reilly logo

Core PHP Programming, Third Edition 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

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 ...

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