Introduction Introduction
Welcome to Sams Teach Yourself PHP, MySQL and Apache All in One, Fourth Edition! In the previous edition, the majority of the modifications were around the ability to use both PHP 5 and MySQL 5 as core technologies. In the two years since the previous edition was released, little has changed: PHP 5 and MySQL 5 are solid, stable, and power a great number of the Web-based applications we use every day. Many hosting providers now offer PHP 5 by default, without support for PHP 4 (which has entered the "end of life" phase), thus ensuring that anyone who wants to use PHP 5 and MySQL 5 can do so without installing these applications on their own (although the first four chapters of this book explain how to do just that). All the code in this edition is based on PHP 5 and, where appropriate, the MySQL Improved Extension (mysqli) in PHP, using MySQL 5 as the back-end database.
Some of you might have heard of PHP 6 or have seen books touting PHP 6 as the core language used. As of this writing in May of 2008, PHP 6 is still in the development stages and has not even entered the release candidate stage of development. Although PHP 6 is likely to reach the release candidate stage before the end of 2008, hosting providers will be loath to provide new technologies for general use until the language and the engine driving it have been thoroughly tested and improved to the point at which the release is deemed stable and matureperhaps sometime in 2009. Given this information, it seemed entirely premature for this edition to cover the aspects of the language based on a developmental release, especially when the goal of this book is to provide the concepts necessary to master the basics of programming in the PHP languagethe version that is stable and widely distributed.
Over the course of this book, you'll learn the concepts necessary for configuring and managing the Apache web server, the basics of programming in PHP, and the methods for using and administering the MySQL relational database system. The overall goal of the book is to provide you with the foundation you need to understand how seamlessly these technologies integrate with one another and to give you practical knowledge of how to integrate them.
Who Should Read This Book?
This book is geared toward individuals who possess a general understanding of the concepts of working in a web-based development environment, be it Linux/UNIX, Windows, or even Mac OS X. Installation and configuration instructions assume that you have familiarity with your operating system and the basic methods of building (on Linux/UNIX systems) or installing (on Windows and Mac OS X systems) software.
The lessons that delve into programming with PHP assume no previous knowledge of the language. However, if you have experience with other programming languages, such as ASP (Active Server Pages), JSP (Java Server Pages), or Perl, you will find the going much easier. Similarly, if you have worked with other databases, such as Oracle or Microsoft SQL Server, you will already possess a solid foundation for working through the MySQL-related lessons.
The only real requirement is that you already understand static web content creation with HTML. If you are just starting out in the world of web development, you will still be able to use this book, but you should consider working through an HTML tutorial. If you are comfortable creating basic pages, you will be fine.
How This Book Is Organized
This book is divided into six parts, corresponding to particular topic groups. You should read the chapters within each part one right after another, with each chapter building on the information found in those before it:
-
Part I, "Getting Up and Running," provides a quick start guide to installation and walks you through the installation and configuration of MySQL, Apache, and PHP in depth. You'll need to complete at least one version of these instructionseither the quick start installation or the longer instructionsbefore moving on unless you already have access to a working installation of these technologies through a hosting provider. Even if you don't need to install and configure MySQL, Apache, and PHP in your development environment, you should still skim these lessons so that you understand the basics of their interaction.
-
Part II, "PHP Language Structure," is devoted to teaching you the basics of the PHP language, including structural elements such as arrays and objects. The examples will get you in the habit of writing code, uploading it to your server, and testing the results.
-
Part III, "Getting Involved with the Code," consists of chapters that cover intermediate-level application development topics, including working with forms and files, restricting access, and completing other small projects designed to introduce a specific concept.
-
Part IV, "PHP and MySQL Integration," contains chapters devoted to working with databases in general, such as database normalization, as well as using PHP to connect to and work with MySQL. Included is a basic SQL primer, which also includes MySQL-specific functions and other information.
-
Part V, "Basic Projects," consists of chapters devoted to performing a particular task using PHP and MySQL, integrating all the knowledge gained so far. Projects include an address book, a discussion forum, and a basic online storefront, among others. These examples are built in a black-and-white environment, meaning the aesthetic display is minimal. This allows you to focus on the programming and logic involved in building the structures rather than making these items aesthetically pleasing.
-
Part VI, "Administration and Fine-Tuning," is devoted to administering and tuning Apache and MySQL. It also includes information on virtual hosting and setting up a secure web server.
If you find that you are already familiar with a topic, you can skip ahead to the next chapter. However, in some instances, chapters refer to specific concepts learned in previous chapters, so be aware that you might have to skim a skipped chapter so that your development environment remains consistent with the book.
At the end of many chapters, a few quiz questions test how well you've learned the material. Additional activities provide another way to apply the information learned in the chapter and guide you toward using this newfound knowledge in the next chapter.
About the Book's Source Code
All of the code that appears in listings throughout the chapters is also available on the accompanying CD-ROM. You may also download the source code bundle from the author's website at http://www.thickbook.com/.
Typing the code on your own provides useful experience in making typos, causing errors, and performing the sometimes mind-numbing task of tracking down errant semicolons. However, if you want to skip that lesson and just upload the working code to your website, feel free!
Conventions Used in This Book
This book uses different typefaces to differentiate between code and plain English, and to help you identify important concepts. Throughout the chapters, code, commands, and text you type or see onscreen appear in a computer typeface. New terms appear in italics at the point in the text where they are defined. Additionally, icons accompany special blocks of information:
Note - A "By the Way" note presents an interesting piece of information related to the current topic.
Tip - A "Did You Know" tip offers advice or teaches an easier method for performing a task.
Caution - A "Watch Out!" warns you about potential pitfalls and explains how to avoid them.
© Copyright Pearson Education. All rights reserved.