Specifications
FIGURE 1.2
Text passed to PHP’s echo construct is echoed to the browser.
None of the raw PHP is visible. This is because the PHP interpreter has run through the script
and replaced it with the output from the script. This means that from PHP we can produce
clean HTML viewable with any browser—in other words, the user’s browser does not need to
understand PHP.
This illustrates the concept of server-side scripting in a nutshell. The PHP has been interpreted
and executed on the Web server, as distinct from JavaScript and other client-side technologies
that are interpreted and executed within a Web browser on a user’s machine.
The code that we now have in this file consists of four things:
• HTML
• PHP tags
• PHP statements
• Whitespace
We can also add
• Comments
Most of the lines in the example are just plain HTML.
Using PHP Tags
The PHP code in the previous example began with <? and ended with ?>. This is similar to all
HTML tags because they all begin with a less than (<) symbol and end with a greater than (>)
symbol. These symbols are called PHP tags that tell the Web server where the PHP code starts
and finishes. Any text between the tags will be interpreted as PHP. Any text outside these tags
will be treated as normal HTML. The PHP tags allow us to escape from HTML.
Using PHP
P
ART I
14
03 7842 CH01 3/6/01 3:39 PM Page 14