PHP Essentials / Edition 2 available in Paperback
- Pub. Date:
- Course Technology, Inc.
|Publisher:||Course Technology, Inc.|
|Product dimensions:||7.38(w) x 9.24(h) x 0.78(d)|
About the Author
Read an Excerpt
Chapter 1: Getting Started with PHPSo, what's all the hoopla about "fip"? First, it's not "fip"-it's P-H-P, from its original name: "Personal Home Page Tools." PHP is a server-side scripting language. When your Web browser accesses an URL, it is making a request to a Web server. If you are requesting a PHP page, something like http://www.yourcompany.com/home.php, the Web server wakes up the PHP parsing engine and says, "Hey! You've got to do something before I send a result back to this person's Web browser." The PHP parsing engine runs through the PHP code found in home. php and returns the resulting output. This output is passed back to the Web server as the HTML code in the document, which in turn is passed on to your browser, which displays it to you.
A Brief History of PNP
In 1994, an incredibly forward-thinking man named Rasmus Lerdorf developed a set of tools that used a parsing engine to interpret a few macros here and there. They were not extravagant: a guest book, a counter, and some other "home page" elements that were cool when the Web was in its infancy. He eventually combined these tools with a form interpretation (FI) package he had written, added some database support, and released what was known as PHP/FI.
Then, in the spirit of Open Source software development, developers all over the world began contributing to PHP/FI. By 1997, more than 50,000 Web sites were using PHP/FI to accomplish different tasks-connecting to a database, displaying dynamic content, and so on.
At that point, the development process really started becoming a team effort. With primary assistance from developers Zeev Suraski and Andi Gutmans, the version 3.0 parser was created. The final release of PHP3 occurred in June of 1998, when it was upgraded to include support for multiple platforms (it's not just for Linux anymore!) and Web servers, numerous databases, and SNMP (Simple Network Management Protocol) and IMAP (Internet Message Access Protocol).
So where are we now? While I'm writing this paragraph just two weeks before the end of 1999, the rapid growth and popularity of PHP are apparent:
- PHP3 is in use on over one million Web servers.
- PHP3 ships with the Red Hat Linux distribution.
- The PPP Development Team is close to releasing a non-beta version of PHP4, featuring a super-fast engine called Zend.
What goes PNP go?
PHP does anything you want, except sit on its head and spin. Actually, with a little on-the-fly image manipulation and Dynamic HTML, it can probably do that, too.
According to the PHP Manual, "The goal of the language is to allow Web developers to write dynamically generated pages quickly" Here are some common uses of PHP:
- Perform system functions: create, open, read from, write to, and close files on your system; execute system commands; create directories; and modify permissions.
- Gather data from forms: save the data to a file, send data via e-mail, return manipulated data to the user.
- Access databases and generate content on-the-fly, or create a Web interface for adding, deleting, and modifying elements within your database.
- Set cookies and access cookie variables.
- Use PHP user authentication to restrict access to sections of your Web site.
- Create images on-the-fly.
- Encrypt data.
The future of pop
The future of PHP has arrived, with the beta release of PHP4 and the Zend engine (created by Zend Technologies). The final version of PHP4 is scheduled for release during the first quarter of 2000, and all signs point to a successful launch...
Table of Contents
Introduction 1. Getting Started with PHP 2. Basic PHP Techniques 3. Working with Databases 4. Creating and Populating Database Tables 5. User Authentication 6. User Tracking and Session Management 7. Advanced PHP Techniques: Web-Based Database Administration 8. Advanced PHP Techniques: Working with Images 9. Advanced PHP Techniques: Working with XML Appendix A: Essential PHP Language Reference Appendix B: Getting Support
If you've been programming with PHP since the beginning of time, there's probably not much you can get out of this book, except to hand it to your boss and say, "Look! Another book on what a wonderful language this is. Can we please stop using ASP/ Cold Fusion/Java/Perl/C++ and migrate to PEP now?" But if you've just dabbled with PHP or have never seen a PHP script, this is the book for you. Whether you're a first-time programmer or you have a few years of Web application development under your belt, you'll find something useful here. I hope what you'll find is a simple "learn-by-example" path to developing highly successful Web sites. Unlike the Web itself, this book is fairly linear. You'll start by installing the software needed to use PHP, and then you'll gradually move into "Hello World!" scripts and eventually create shopping carts and other database-driven applications.
If you have an account with an Internet Service Provider that has enabled the use of PHP for all users on the server, you can skip ahead to Chapter 2. But since you can install freely-available Web servers, PHP, and a database or two on your own machine with a little poking and prodding along the way, I recommend doing so. It's a great way to learn the "guts" of what you're doing (and it looks good on a resume!).
For More Stuff
This book has its own Web site (that figures, doesn't it?), at http:// www.thickbook.com/. At this site you can download all of the code samples in this book, as well as all of the samples I didn't include, such as examples geared toward alternative database types. You can also use the site to alert me to bugs and other problems you have with the examples. Although they have been tested many times, one errant semicolon or quotation mark can cause the dreaded parse error. Also, please use the Web site to tell me about examples you wish I had included. I'll do my best to keep the "Tutorials" section filled with new and exciting topics not covered in this book.