As discussed previously, PHP scripts are surrounded by the
PHP start tag
<?php and the end tag
You’ll often see the start tag abbreviated as
<?, but this conflicts with the emerging XHTML
standard and should be avoided.
Statements in a script are terminated with a semicolon. Statements can be formatted for readability by including any amount of whitespace—such as space characters, tab characters, or blank lines—in a script.
Comments can be included in a PHP script using the following styles:
// One line comment # Another one line comment /* A multiple line comment */
Data can be output with the statements
The first two are often interchangeable, but
has an advantage in that it can take more than one argument. The
printf statement is used for more complex output
and is identical to that used in other programming languages such as
C and scripting languages such as awk. Consider
a few examples:
// These are the same echo "This is output"; print "This is output"; // echo can output more than one argument echo 123, "is a number"; // printf can be used to control formatting // This outputs 3.14 printf("pi is %.2f\n", 3.14159);
Variables are identified by the prefix ...