O'Reilly logo

PHP & MySQL: The Missing Manual, 2nd Edition by Brett McLaughlin

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

Chapter 3. PHP Syntax: Weird and Wonderful

You’ve got a couple of PHP programs running, and have a handle on how PHP can interact with an HTML form. Still, although you’re a little more comfortable with how PHP as a whole interacts with web servers and web browsers, what’s actually going on in those PHP scripts? It’s time to dig a good deal deeper and start to understand what’s going on in the code you’re writing. In this chapter, you’re going to get comfortable with a lot of the PHP syntax. That means learning what special words—usually called keywords—you type into your programs and what each one of those keywords instructs PHP to do.

Fortunately, this learning doesn’t mean you can’t still build interesting programs that run in a web browser. In fact, because almost everything that’s done with PHP involves web pages, all of your scripts in this chapter will accept information from a web form and work with that information. So, you’re not just learning PHP; you’re learning to write web applications.

Get Information from a Web Form

In sayHelloWeb.php, you used the following line to get the value of a variable called “name” from the sayHello.html web form:

echo $_REQUEST['name'];

You might remember that $_REQUEST is a special PHP variable that lets you get information from a web request (Check Things Out Locally). You used it to get one particular piece of information—the user’s name—but it can do a lot more.

Note

You can find the finished example code for this section on this book’s Missing ...

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