O'Reilly logo

Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP by Brent Ware, James Lee

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

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

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