PHP6 and MySQL
What Is PHP?
PHP is an open source, server-side, HTML-embedded web-scripting language that is compatible with all the major web servers (most notably Apache). PHP enables you to embed code fragments in normal HTML pages — code that is interpreted as your pages are served up to users. PHP also serves as a “glue” language, making it easy to connect your web pages to server-side databases.
Why PHP?
We devote nearly all of Chapter 1 to this question. The short answer is that it’s free, it’s open source, it’s full featured, it’s cross-platform, it’s stable, it’s fast, it’s clearly designed, it’s easy to learn, and it plays well with others.
What’s New in This Edition?
This book is a new edition of the popular PHP Bible and PHP5 and MySQL Bible series. The book updates the elements from previous versions, where applicable, for PHP 6 and MySQL 6.
New PHP 6 features
Although much of PHP 5’s functionality survives unchanged in PHP 6, there have been some changes. Among the ones we cover are:
- Unicode support, making internationalization easier
- Security enhancements such as removing safe mode and register global
- Enhancements to the object-oriented interfaces
Who wrote the book?
The first two editions were by Converse and Park, with a guest chapter by Dustin Mitchell and tech editing by Richard Lynch. For the third edition, Clark Morgan took on much of the revision work, with help from Converse and Park as well as from David Wall and Chris Cornell, who also contributed chapters and did technical editing. For this edition, Steve Suehring did revision work with Aaron Saray providing technical editing.
Whom This Book Is For
This book is for anyone who wants to build web sites that exhibit more complex behavior than is possible with static HTML pages. Within that population, we had the following three particular audiences in mind:
- Web site designers who know HTML and want to move into creating dynamic web sites
- Experienced programmers (in C, Java, Perl, and so on) without web experience who want to quickly get up to speed in server-side web programming
- Web programmers who have used other server-side technologies (Active Server Pages, Java Server Pages, or ColdFusion, for example) and want to upgrade or simply add another tool to their kit
We assume that the reader is familiar with HTML and has a basic knowledge of the workings of the web, but we do not assume much programming experience beyond that. To help save time for more experienced programmers, we include a number of notes and asides that compare PHP with other languages and indicate which chapters and sections may be safely skipped. Finally, see our appendixes, which offer specific advice for C programmers, ASP coders, and pure-HTML designers.
This Book Is Not the Manual
The PHP Documentation Group has assembled a great online manual, located at www.php.net and served up (of course) by PHP. This book is not that manual or even a substitute for it. We see the book as complementary to the manual and expect that you will want to go back and forth between them to some extent.
In general, you’ll find the online manual to be very comprehensive, covering all aspects and functions of the language, but inevitably without a great amount of depth in any one topic. By contrast, we have the leisure of zeroing in on aspects that are most used or least understood and give background, explanations, and lengthy examples.
How the Book Is Organized
This book is divided into five parts, as the following sections describe.
Part I: PHP: The Basics
This part is intended to bring the reader up to speed on the most essential aspects of PHP, with complexities and abstruse features deferred to later parts.
- Chapters 1 through 3 provide an introduction to PHP and tell you what you need to know to get started.
- Chapters 4 through 9 are a guide to the most central facets of PHP (with the exception of database interaction): the syntax, the data types, and the most basic built-in functions.
- Chapter 10 is a guide to the most common pitfalls of PHP programming.
Part II: PHP and MySQL
Part II is devoted both to MySQL and to PHP’s interaction with MySQL.
- Chapters 11 and 12 provide a general orientation to web programming with SQL databases, including installation of MySQL.
- Chapter 13 covers Structured Query Language (SQL), and Chapter 14 covers database administration basics.
- Chapter 15 is devoted to PHP functions for MySQL.
- Chapters 16 and 17 are detailed, code-rich case studies of PHP/MySQL interactions.
- Chapters 18 and 19 provide tips and gotchas specific to PHP/MySQL work.
Part III: Advanced Techniques
In this part we cover more advanced features of PHP, usually as self-contained chapters, including object-oriented programming, session handling, exception handling, using cookies, and regular expressions.
- Chapter 31 is a tour of debugging techniques, and Chapter 32 discusses programming style.
Part IV: Connections
In this part we cover advanced techniques and features that involve PHP talking to other services, technologies, or large bodies of code.
- Chapters 33 through 36 cover PHP’s interaction with other database technologies (PostgreSQL, Oracle, PDO, and SQLite).
- Chapters 37 through 42 cover self-contained topics: PHP and e‑mail programs, combining
PHP with JavaScript, integrating PHP and Java, PHP and XML, PHP-based Web services, and creating graphics with the gd image library.
Part V: Case Studies
Here we present three extended case studies that wrap together techniques from various early chapters.
- Chapter 43 takes you through the design and implementation of a weblog.
- Chapter 44 discusses a soup-to-nuts implementation of a novel trivia quiz game.
- Chapter 45 uses the gd image library to visualize data from a MySQL database.
Appendices
At the end, we offer three “quick-start” appendixes, for use by people new to PHP but very familiar with either C (Appendix A), Perl (Appendix B), or pure HTML (Appendix C). If you are in any of these three situations, start with the appropriate appendix for an orientation to important differences and a guide to the book. Appendix (D) is a guide to important resources, web sites, and mailing lists for the PHP community. The final appendix (E) is information on the PEAR repository, which is no longer scheduled to be included in PHP 6. However, this information (from a previous edition of the book) may be helpful to someone maintaining a PHP site on an earlier version of PHP or one that uses PEAR.
Conventions Used in This Book
We use a moonscapes font to indicate literal PHP code. Pieces of code embedded in lines of text look like this, while full code listing lines look as follows: print(“this”);
If the appearance of a PHP-created web page is crucial, we include a screenshot. If it is not, we show textual output of PHP in monospaced font. If we want to distinguish the PHP output as seen in your browser from the actual output of PHP (which your browser renders), we call the former browser output.
If included in a code context, italics indicate portions that should be filled in appropriately, as opposed to being taken literally. In normal text, an italicized term means a possibly unfamiliar word or phrase.
0 comments:
Post a Comment