Specifications

way they did, when it was last modified, and so on. You will generally find comments in all
but the simplest PHP scripts.
The PHP interpreter will ignore any text in a comment. Essentially the PHP parser skips over
the comments that are equivalent to whitespace.
PHP supports C, C++, and shell script style comments.
This is a C-style, multiline comment that might appear at the start of our PHP script:
/* Author: Bob Smith
Last modified: April 10
This script processes the customer orders.
*/
Multiline comments should begin with a /* and end with */. As in C, multiline comments can-
not be nested.
You can also use single line comments, either in the C++ style:
echo “<p>Order processed.”; // Start printing order
or in the shell script style:
echo “<p>Order processed.”; # Start printing order
With both of these styles, everything after the comment symbol (# or //) is a comment until
we reach the end of the line or the ending PHP tag, whichever comes first.
Adding Dynamic Content
So far, we havent used PHP to do anything we couldnt have done with plain HTML.
The main reason for using a server-side scripting language is to be able to provide dynamic
content to a sites users. This is an important application because content that changes accord-
ing to a users needs or over time will keep visitors coming back to a site. PHP allows us to do
this easily.
Lets start with a simple example. Replace the PHP in processorder.php with the following
code:
<?
echo “<p>Order processed at “;
echo date(“H:i, jS F”);
echo “<br>”;
?>
In this code, we are using PHPs built-in date() function to tell the customer the date and time
when his order was processed. This will be different each time the script is run. The output of
running the script on one occasion is shown in Figure 1.3.
PHP Crash Course
C
HAPTER 1
1
PHP CRASH
COURSE
17
03 7842 CH01 3/6/01 3:39 PM Page 17