Page 49 - Beginning PHP 5.3
P. 49

2















                                  Your First PHP Script





                           Now that you have a feel for what PHP is, it ’ s time to dive in and start writing PHP programs.
                         To do this, you ’ ll first need access to a Web server running PHP. This chapter kicks off by showing
                         you, in simple terms, how to install the following programs on your computer:
                            ❑     The Apache Web server
                            ❑     The PHP engine
                            ❑       The MySQL database server

                           You also learn a bit about troubleshooting Web servers as you go.

                               The installation process is fairly straightforward; however if you ’ re put off by the idea of having
                             to install these programs on your computer, you can instead run your PHP scripts on a remote
                             Web server that ’ s already set up for the job (see the section  “ Running PHP Remotely ”  later in the
                             chapter).

                           Once you have PHP up and running, you get to create your first PHP script. Along the way, you
                         learn how you can embed PHP code within an HTML Web page, which is one of the fundamental
                         concepts of PHP.
                           You then extend your script to display some dynamic information in the page  —  in this case, the
                         current time  —  and you also learn about comments: how to write them, and why they ’ re useful.

                          Once you ’ ve followed this chapter, you ’ ll have a basic understanding of how to install PHP, and
                         you ’ ll have learned how PHP scripts are put together. This is all useful knowledge that you ’ ll build
                         on in later chapters. So let ’ s get going!


















                                                                                                      9/21/09   8:50:18 AM
          c02.indd   11                                                                               9/21/09   8:50:18 AM
          c02.indd   11
   44   45   46   47   48   49   50   51   52   53   54