13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

26 Chapter 1 <strong>PHP</strong> Crash Course<br />

Figure 1.4<br />

The form variables the user typed in are easily accessible in<br />

processorder.php.<br />

The following sections describe a couple of interesting elements of this example.<br />

String Concatenation<br />

In the sample script, echo prints the value the user typed in each form field, followed by<br />

some explanatory text. If you look closely at the echo statements, you can see that the<br />

variable name <strong>and</strong> following text have a period (.) between them, such as this:<br />

echo $tireqty.’ tires’;<br />

This period is the string concatenation operator, which adds strings (pieces of text)<br />

together.You will often use it when sending output to the browser with echo.This way,<br />

you can avoid writing multiple echo comm<strong>and</strong>s.<br />

You can also place simple variables inside a double-quoted string to be echoed.<br />

(Arrays are somewhat more complicated, so we look at combining arrays <strong>and</strong> strings in<br />

Chapter 4,“String Manipulation <strong>and</strong> Regular Expressions.”) Consider this example:<br />

echo “$tireqty tires”;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!