12.5. Language Syntax

Like the other languages we’ve studied (and most easy-to-use languages), PHP is whitespace-insensitive. Therefore, this statement:

<?  $title="PHP is cool";echo "<title> $title </title>"; ?> 

might be clearer if written as this:

<? 
    $title = "PHP is cool"; 
    echo "<title> $title </title>"; 
?> 

Variable names in PHP are case-sensitive—$a is different from $A. Function names (including user-defined functions) are case-insensitive—rose() is equivalent to ROSE() is equivalent to Rose().

As in C, C++, Java, and Perl, statements are terminated by a semicolon. Also as in C, C++, and Java (but not Perl), single-line bodies do not require the curly braces ({}), while multiline bodies do:

 <? // one-line bodies do not require the curlies, ...

Get Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP 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.