|
Chapter 3
Creating Your First PHP Script
In This Chapter
Writing PHP statements
Adding PHP sections to HTML files
Writing PHP output statements
Documenting your scripts
A
PHP statementis an instruction that tells PHP to perform an action. A
PHP scriptis a series of PHP statements. Theoretically, a script can con-
tain as few as one statement, but it’s unlikely that any practical script would
consist of a single statement. In most cases, you write scripts that contain
several statements in a row. PHP executes the statements one at a time until
it reaches the end of the script.
As discussed in Chapter 1, PHP can do many things, and scripts are the
method you use to tell PHP what you want it to do. You can tell it to display
some text on a Web page or to store data that a user entered into a form on
your Web page. PHP can also do things that are unrelated to Web sites, such
as back up all the files in a directory on your hard disk. You can write simple
scripts that just display
hello
in a Web browser. Or you can write complicated
scripts that display different things in the Web browser for different people,
or request passwords from Web site visitors and refuse access to visitors who
don’t enter valid passwords. Applications often consist of two or more scripts
that work together to accomplish the job required. A large, complicated appli-
cation, such as an e-commerce application, can consist of many scripts.
In this chapter, I explain how to write your first script. I also discuss output
statements, which are the most common PHP statements. Finally, I illustrate
the importance of documenting your script.
|