Beginning PHP and MySQL 4th Edition.pdf

(4817 KB) Pobierz
THE EXPERT’S VOICE
® 
IN WEB DEVELOPMENT
PHP
and
MySQL
FOURTH EDITION
Beginning
From Novice to Professional
Learn how to build dynamic, database-driven web sites using
two of the world’s most popular open source technologies
W. Jason Gilmore
Beginning PHP
and MySQL
From Novice to Professional
Fourth Edition

W. Jason Gilmore
Beginning PHP and MySQL: From Novice to Professional, Fourth Edition
Copyright © 2010 by W. Jason Gilmore
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-4302-3114-1
ISBN-13 (electronic): 978-1-4302-3115-8
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of
the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject
to proprietary rights.
President and Publisher: Paul Manning
Lead Editor: Michelle Lowman
Development Editor: Tom Welsh
Technical Reviewer: Matt Wade
Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan
Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper,
Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom
Welsh
Coordinating Editors: Anne Collett and Jennifer L. Blackwell
Copy Editor: Mary Behr
Compositor: Bytheway Publishing Services
Indexer: BIM Indexing & Proofreading Services
Artist: April Milne
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
orders-ny@springer-
sbm.com,
or visit
www.springeronline.com.
For information on translations, please e-mail
rights@apress.com,
or visit
www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our
Special Bulk Sales–eBook Licensing web page at
www.apress.com/info/bulksales.
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have
any liability to any person or entity with respect to any loss or damage caused or alleged to be caused
directly or indirectly by the information contained in this work.
The source code for this book is available to readers at
www.apress.com.
CONTENTS AT A GLANCE
Contents at a Glance
About the Author................................................................................................ xxix
About the Technical Reviewer ............................................................................ xxx
Acknowledgments ............................................................................................. xxxi
Introduction ...................................................................................................... xxxii
Chapter 1: Introducing PHP ....................................................................................1
Chapter 2: Configuring Your Environment ..............................................................9
Chapter 3: PHP Basics ..........................................................................................41
Chapter 4: Functions.............................................................................................91
Chapter 5: Arrays................................................................................................103
Chapter 6: Object-Oriented PHP..........................................................................135
Chapter 7: Advanced OOP Features ....................................................................159
Chapter 8: Error and Exception Handling............................................................175
Chapter 9: Strings and Regular Expressions ......................................................191
Chapter 10: Working with the File and Operating System..................................229
Chapter 11: PEAR................................................................................................257
Chapter 12: Date and Time .................................................................................269
Chapter 13: Working with HTML Forms ..............................................................287
Chapter 14: Authenticating Your Users ..............................................................303
Chapter 15: Handling File Uploads......................................................................319
Chapter 16: Networking......................................................................................331
Chapter 17: PHP and LDAP..................................................................................351
iii
CONTENTS AT A GLANCE
Chapter 18: Session Handlers.............................................................................367
Chapter 19: Templating with Smarty..................................................................387
Chapter 20: Web Services...................................................................................411
Chapter 21: Securing Your Web Site...................................................................427
Chapter 22: Creating Ajax-enhanced Features with jQuery and PHP .................437
Chapter 23: Building Web Sites for the World ....................................................449
Chapter 24: Introducing the Zend Framework....................................................457
Chapter 25: Introducing MySQL ..........................................................................477
Chapter 26: Installing and Configuring MySQL ...................................................487
Chapter 27: The Many MySQL Clients .................................................................505
Chapter 28: MySQL Storage Engines and Data Types .........................................527
Chapter 29: Securing MySQL ..............................................................................557
Chapter 30: Using PHP with MySQL ....................................................................587
Chapter 31: Introducing PDO ..............................................................................607
Chapter 32: Stored Routines...............................................................................627
Chapter 33: MySQL Triggers ...............................................................................649
Chapter 34: MySQL Views...................................................................................659
Chapter 35: Practical Database Queries .............................................................673
Chapter 36: Indexes and Searching ....................................................................693
Chapter 37: Transactions....................................................................................709
Chapter 38: Importing and Exporting Data .........................................................719
Index ...................................................................................................................733
iv
Zgłoś jeśli naruszono regulamin