Now that you are aware of how PHP scripts are executed, let's discuss how to actually write your first PHP script. All PHP scripts are written in what are called code blocks. These blocks can be embedded into HTML, if desired, and are generally defined by <?php at the start and ?> at the end. Everything outside of these block identifiers will be ignored by the PHP interpreter and instead passed directly back to the Web server to be displayed to the client.
As you would expect, the first three lines of this simple PHP script are ignored and passed directly to the output of the script. The fourth line, however, is executed by PHP, and the string "Hello world!" is printed to the browser, followed by the rest of the ignored HTML text. You have learned your first PHP statementthe echo statement. This statement is the basic method in PHP to display content back to the client, and you'll be using it extensively throughout the book. Also note that, as with other C-style languages, each statement ends with a semicolon.