HTML and CSS Reference
If you're a Mac user, you also have the option of using MAMP, another free package that
combines Apache, PHP, and MySQL. It can be downloaded from http://www.mamp.info.
Mac users also have the option of using the version of Apache and PHP that are included
with OS X.
After you've installed XAMPP (or MAMP), you just have to start the application to get a
web server up and running that you can use to develop your pages. To test your PHP
pages, you can put them in the htdocs directory inside the XAMPP install directory. For
example, if you want to test the hello.php page I talked about earlier, you could put it in
the htdocs directory. To view it, just go to http://localhost/hello.php.
If that doesn't work, make sure that XAMPP has started the Apache server. If you're
using MAMP, the steps are basically the same. Just put your pages in the htdocs folder,
as with XAMPP.
When you think about the English language, you think about it in terms of parts of
speech. Nouns name things, verbs explain what things do, adjectives describe things, and
so on. Programming languages are similar. A programming language is made up of vari-
ous “parts of speech,” too. In this section, I explain the parts of speech that make up the
PHP language—comments, variables, conditional statements, and functions.
similar between the two. If things such as the comment format, curly braces, and control
statements look similar from one to the other, it's because they are.
styles: one for single-line comments, and another for multiple comments. (If you're
familiar with comments in the C or Java programming language, you'll notice that PHP's
are the same.) First, single-line comments. To start a single-line comment, use // or # .
Everything that follows either on a line is treated as a comment. Here are some exam-
// My function starts here.
$color = 'red'; // Set the color for text on the page
# $color = 'blue';
$color = $old_color; # Sets the color to the old color.
// $color = 'red';