logo资料库

php英文学习资料.pdf

第1页 / 共915页
第2页 / 共915页
第3页 / 共915页
第4页 / 共915页
第5页 / 共915页
第6页 / 共915页
第7页 / 共915页
第8页 / 共915页
资料共915页,剩余部分请下载后查看
PHP6 and MySQL Bible
About the Authors
Credits
Acknowledgments
Contents at a Glance
Contents
Introduction
What Is PHP?
Why PHP?
What’s New in This Edition?
Whom This Book Is For
This Book Is Not the Manual
How the Book Is Organized
Conventions Used in This Book
What the Icons Mean
Part I: Introducing PHP
Chapter 1: Why PHP and MySQL?
What Is PHP?
What Is MySQL?
Deciding on a Web Application Platform
Summary
Chapter 2: Server-Side Scripting Overview
Static HTML
Client-Side Technologies
Server-Side Scripting
What Is Server-Side Scripting Good For?
Summary
Chapter 3: Getting Started with PHP
Installing PHP
What’s to Come?
Your HTML Is Already PHP-Compliant!
Escaping from HTML
Summary
Chapter 4: Learning PHP Syntax and Variables
PHP Is Forgiving
HTML Is Not PHP
PHP’s Syntax Is C-Like
Comments
Variables
Types in PHP: Don’t Worry, Be Happy
Type Summary
The Simple Types
Output
Summary
Chapter 5: Learning PHP Control Structures and Functions
Boolean Expressions
Branching
Looping
Alternate Control Syntaxes
Terminating Execution
Using Functions
Function Documentation
Defining Your Own Functions
Functions and Variable Scope
Function Scope
Summary
Chapter 6: Passing Information with PHP
HTTP Is Stateless
GET Arguments
A Better Use for GET-Style URLs
POST Arguments
Formatting Form Variables
PHP Superglobal Arrays
Summary
Chapter 7: Learning PHP String Handling
Strings in PHP
String Functions
Summary
Chapter 8: Learning Arrays
The Uses of Arrays
What Are PHP Arrays?
Creating Arrays
Retrieving Values
Multidimensional Arrays
Inspecting Arrays
Deleting from Arrays
Iteration
Summary
Chapter 9: Learning PHP Number Handling
Numerical Types
Mathematical Operators
Simple Mathematical Functions
Randomness
Summary
Chapter 10: PHP Gotchas
Installation-Related Problems
Rendering Problems
Failures to Load Page
Parse Errors
Missing Includes
Unbound Variables
Function Problems
Math Problems
Timeouts
Summary
Part II: MySQL Database Integration
Chapter 11: Introducing Databases and MySQL
What Is a Database?
Why a Database?
PHP-Supported Databases
Our Focus: MySQL
Summary
Chapter 12: Installing MySQL
Obtaining MySQL
Installing MySQL on Linux
Installing MySQL on Microsoft Windows
Summary
Chapter 13: Learning Structured Query Language (SQL)
Relational Databases and SQL
SQL Standards
The Workhorses of SQL
Database Design
Privileges and Security
Summary
Chapter 14: Learning Database Administration and Design
Basic MySQL Client Commands
MySQL User Administration
Backups
Replication
Recovery
Summary
Chapter 15: Integrating PHP and MySQL
Connecting to MySQL
Making MySQL Queries
Fetching Data Sets
Getting Data about Data
Multiple Connections
Building in Error Checking
Creating MySQL Databases with PHP
MySQL Functions
Summary
Chapter 16: Performing Database Queries
HTML Tables and Database Tables
Complex Mappings
Creating the Sample Tables
Summary
Chapter 17: Integrating Web Forms and Databases
HTML Forms
Basic Form Submission to a Database
Self-Submission
Editing Data with an HTML Form
Summary
Chapter 18: Improving Database Efficiency
Connections—Reduce, Reuse, Recycle
Indexing and Table Design
Making the Database Work for You
Summary
Chapter 19: MySQL Gotchas
No Connection
Problems with Privileges
Unescaped Quotes
Broken SQL Statements
Too Little Data, Too Much Data
Specific SQL Functions
Debugging and Sanity Checking
Summary
Part III: More PHP
Chapter 20: Introducing Object-Oriented PHP
What Is Object-Oriented Programming?
Basic PHP Constructs for OOP
Advanced OOP Features
Introspection Functions
Extended Example: HTML Forms
Gotchas and Troubleshooting
OOP Style in PHP
Summary
Chapter 21: Advanced Array Functions
Transformations of Arrays
Stacks and Queues
Translating between Variables and Arrays
Sorting
Printing Functions for Visualizing Arrays
Summary
Chapter 22: Examining Regular Expressions
Tokenizing and Parsing Functions
Why Regular Expressions?
Perl-Compatible Regular Expressions
Example: A simple link-scraper
Advanced String Functions
Summary
Chapter 23: Working with the Filesystem
Understanding PHP File Permissions
File Reading and Writing Functions
Filesystem and Directory Functions
Network Functions
Date and Time Functions
Calendar Conversion Functions
Summary
Chapter 24: Working with Cookies and Sessions
What’s a Session?
Home-grown Alternatives
How Sessions Work in PHP
Sample Session Code
Session Functions
Configuration Issues
Cookies
Sending HTTP Headers
Gotchas and Troubleshooting
Summary
Chapter 25: Learning PHP Types
Type Round-up
Resources
Type Testing
Assignment and Coercion
Summary
Chapter 26: Learning PHP Advanced Functions
Variable Numbers of Arguments
Call-by-value
Call-by-reference
Variable function names
An extended example
Summary
Chapter 27: Performing Math with PHP
Mathematical Constants
Tests on Numbers
Base Conversion
Exponents and Logarithms
Trigonometry
Arbitrary Precision (BC)
Summary
Chapter 28: Securing PHP
Possible Attacks
FYI: Security Web Sites
Summary
Chapter 29: Learning PHP Configuration
Viewing Environment Variables
Understanding PHP Configuration
Improving PHP Performance
Summary
Chapter 30: Handing Exceptions with PHP
Error Handling in PHP
Other Methods of Error Handling
Logging and Debugging
Summary
Chapter 31: Debugging PHP Programs
General Troubleshooting Strategies
A Menagerie of Bugs
Using Web Server Logs
PHP Error Reporting and Logging
Error-Reporting Functions
Summary
The Uses of Style
Chapter 32: Learning PHP Style
Readability
Maintainability
Robustness
Efficiency and Conciseness
HTML Mode or PHP Mode?
Separating Code from Design
Summary
Part IV: Other Databases
Chapter 33: Connecting PHP and PostgreSQL
Why Choose PostgreSQL?
Why Object-Relational Anyway?
Down to Real Work
PHP and PostgreSQL
The Cartoons Database
Summary
Chapter 34: Using PEAR DB with PHP
Pear DB Concepts
PEAR DB Functions
Summary
Chapter 35: An Overview of Oracle
When Do You Need Oracle?
Oracle and Web Architecture
Using OCI8 Functions
Project: Point Editor
Project: Batch Editor
Summary
Chapter 36: An Introduction to SQLite
An Introduction to SQLite
Using SQLite-related Functions
More on SQLite
Summary
Part V: Connections
Chapter 37: Sending E-Mail with PHP
Sending E-Mail with PHP
Sending Mail from a Form
Summary
Chapter 38: Integrating PHP and Java
PHP for Java programmers
Integrating PHP and Java
Summary
Chapter 39: Integrating PHP and JavaScript
Outputting JavaScript with PHP
PHP as a Backup for JavaScript
Static versus Dynamic JavaScript
Summary
Chapter 40: Integrating PHP and XML
What Is XML?
Working with XML
Documents and DTDs
SAX versus DOM
DOM
SAX
SimpleXML API
A Sample XML Application
Gotchas and Troubleshooting
Summary
Chapter 41: Creating and Consuming Web Services with PHP
The End of Programming as We Know It
REST, XML-RPC, SOAP, . NET
Current Issues with Web Services
Project: A REST Client
Summary
Chapter 42: Creating Graphics with PHP
Your Options
HTML Graphics
Creating images using gd
Gotchas and Troubleshooting
Summary
Part VI: Case Studies
Chapter 43: Developing a Weblog with PHP
Why Weblogs?
The Simplest Weblog
Adding an HTML-Editing Tool
Changes and Additions
Summary
Chapter 44: A Trivia Game
Concepts Used in This Chapter
The Game
The Code
General Design Considerations
Summary
Chapter 45: Data Visualization with Venn Diagrams
Scaled Venn diagrams
Outline of the code
Necessary Trigonometry
Planning the Display
Display
Visualizing a Database
Extensions
Summary
Appendix A: PHP for C Programmers
Similarities
Differences
Guide to the Book
A Bonus: Just Look at the Code!
Appendix B: PHP for Perl Hackers
Similarities
Differences
Miscellaneous Tips
Guide to the Book
Appendix C: PHP for HTML Coders
The Good News
The Bad News
Concentrate On . . .
Avoid at First . . .
Consider This . . .
Appendix D: PHP Resources
The PHP Web Site
The PHP Mailing Lists
Other PHP Web Sites
Appendix E: PEAR
What Is PEAR?
The PEAR Package System
PHP Foundation Classes (PFC)
PHP Extension Code Library (PECL)
The PEAR Coding Style
Summary
Index
Steve Suehring is a technology consultant with a diverse business and computing background. He is the former security editor for LinuxWorld Magazine and has published several books. Tim Converse is a software engineer at Inktomi Corporation, which is owned by Yahoo!. He has more than a dozen years of programming experience in Lisp, C, C++, Java, and Web techniques, including PHP. Joyce Park is a Web developer in Silicon Valley. She has worked on PHP projects of all sizes, including co-lead of the Mod-pulsub project. Harness PHP and MySQL for robust Web development Start quickly building dynamic Web applications with the leading open-source scripting tool, the leading open-source database, and this comprehensive guide that shows you exactly how to do it. You’ll learn PHP6 and MySQL inside and out, explore the ups and downs of using open-source technologies, and discover pages of tips and techniques that help you get the most out of this powerful development duo. Th is book includes extensive code examples, full working applications, and much more. Install, develop, debug, and troubleshoot the newest versions of PHP and MySQL Get up to speed on PHP basics, including syntax, datatypes, functions, and pitfalls Review Structured Query Language (SQL) and data administration basics Master advanced PHP features, including object-oriented programming and session handling Examine PHP’s interaction with other databases technologies, such as Oracle® Explore advanced topics, such as PHP with e-mail programs, and PHP and XML Learn how to create a game and much more in extended case studies Spine: 1.824" P H P 6 a n d M y S Q L® Shelving Category: COMPUTERS / Internet / Web Page Design Reader Level: Beginning to Advanced $49.99 USA $59.99 Canada Suehring, Converse, Park Steve Suehring, Tim Converse, and Joyce Park PHP6 and MySQL® Explore PHP syntax, datatypes, and functions Create database-driven, dynamic Web sites Master server-side Web programming The book you need to succeed! www.cxy808.com
84503ffirs.indd 2 12/16/08 1:09:21 PM www.cxy808.com
PHP 6 and MySQL® 6 Bible 84503ffirs.indd 1 12/16/08 1:09:21 PM www.cxy808.com
84503ffirs.indd 2 12/16/08 1:09:21 PM www.cxy808.com
PHP 6 and MySQL® 6 Bible Steve Suehring Tim Converse Joyce Park 84503ffirs.indd 3 12/16/08 1:09:22 PM www.cxy808.com
PHP 6 and MySQL 6 Bible Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-38450-3 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Library of Congress Cataloging-in-Publication Data Suehring, Steve. PHP 6 and MySQL 6 bible / Steve Suehring. p. cm. Includes index. ISBN 978-0-470-38450-3 (pbk.) 1. PHP (Computer program language) 2. MySQL (Electronic resource) I. Title. QA76.73.P224S94 2009 005.2’762 — dc22 2008048198 Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. MySQL is a registered trademark of MySQL AB in the United States, European Union, and other countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc. is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. 84503ffirs.indd 4 12/16/08 1:09:22 PM www.cxy808.com
About the Authors Steve Suehring is a technology consultant with a diverse business and computing background. Steve’s extensive experience enables him to work cross-functionally within organizations to help create computing architectures that fit the business need. Steve has written several books and mag- azine articles and contributed to many others. Steve has spoken internationally at user groups and conventions. When he has the chance, Steve plays just about any sport or any musical instrument, some with better success than others. Tim Converse has written software to recommend neckties, answer questions about space sta- tions, pick value stocks, and make simulated breakfast. He has an M.S. in Computer Science from the University of Chicago, where he taught several programming classes. He is now an engineering manager in the Web search group at Yahoo!. Joyce Park has an M.A. in history from the University of Chicago, and has worked for several Silicon Valley startups including Epinions, KnowNow, and Friendster. She is a co-lead of the Mod-pubsub Open Source project. 84503ffirs.indd 5 12/16/08 1:09:22 PM www.cxy808.com
Credits Acquisitions Editor Jenny Watson Development Editor Christopher J. Rivera Technical Editor Aaron Saray Production Editor Rachel McConlogue Copy Editor Foxxe Editorial Services Editorial Manager Mary Beth Wakefield Production Manager Tim Tate Vice President and Executive Publisher Barry Pruett Associate Publisher Jim Minatel Project Coordinator, Cover Lynsey Stanford Compositor Jeffrey Wilson, Happenstance Type-O-Rama Proofreader Publication Services, Inc. Indexer Ted Laux Cover Illustration Joyce Haughey Vice President and Executive Group Publisher Richard Swadley Cover Designer Michael E. Trent 84503ffirs.indd 6 12/16/08 1:09:23 PM www.cxy808.com
分享到:
收藏