PHP 5 in Practice

Elliott White, Jonathan D. Eisenhamer

  • 出版商: SAMS
  • 出版日期: 2006-07-21
  • 售價: $1,780
  • 貴賓價: 9.5$1,691
  • 語言: 英文
  • 頁數: 456
  • 裝訂: Paperback
  • ISBN: 0672328887
  • ISBN-13: 9780672328886
  • 相關分類: PHP
  • 已絕版
    無現貨庫存(No stock available)




With the release of PHP 5 web developers need a guide to developing with PHP 5 to both learn its complex new features and more fully implement the long-standing features on which PHP's success is built. PHP 5 in Practice is a reference guide that provides developers with easy-to-use and easily extensible code to solve common PHP problems. It focuses on providing real code solutions to problems, allowing the reader to learn by seeing exactly what is happening behind the scenes to get your solution. Because a real-life situation will rarely match the book's example problems precisely, PHP 5 in Practice explains the solution well enough that you will understand it and can learn how to truly solve your own problem.



Table of Contents


Part I   PHP Internals

1   Strings  

1.1 Matching Patterns (Regular Expressions) 

1.2 Cleaning Up Whitespace 

1.3 Expanding and Compressing Tabs  

1.4 Converting Text Between Macintosh, UNIX, and PC Format  

1.5 Parsing CSV (Comma-Separated Values)  

1.6 Truncating Text to Fit Within a Specific Space  

1.7 Padding Arrays of Data to Display as Columns  

1.8 Checking the Spelling of a Word  

1.9 Matching Similar Strings  

1.10 Performing Proper Capitalization on Titles  

1.11 Generating Unique Identifiers  

1.12 Counting the Number of Times Certain Words Appear

2   Numbers  

2.1 Retrieving a Number from a String  

2.2 Printing Proper Plural Text  

2.3 Converting Numbers into Roman Numerals  

2.4 Calculating Interest  

2.5 Simulating Dice  

2.6 Latitude/Longitude Calculations  

2.7 Metric/English Conversion  

2.8 Temperature Conversion  

2.9 Statistics Package Creation  

3   Time and Date  

3.1 Calculating the Difference Between Two Dates  

3.2 Determining Last Day of a Given Month  

3.3 Leap Year Calculation  

3.4 Handling Time Zones  

3.5 Handling Time Stamps Within Databases or in Files  

3.6 Determining Number of Business Days  

3.7 Generating a Calendar for a Given Month  

4   Variables  

4.1 Determining Whether a Variable Is Equal to Another  

4.2 Accessing a Variable Outside a Function, from Within it (Global Variables)  

4.3 Keeping a Persistent Value Within a Function (Static Variables)  

4.4 Having One Variable Refer to Another (References)  

4.5 Using a Variable to Hold the Name of Another Variable  

4.6 Declaring a Constant Instead of a Variable  

4.7 Coalescing a List of Values to Determine the First Non-False Value  

5   Arrays  

5.1 Superglobal Arrays and Their Usage  

5.2 Stack Implementation  

5.3 Queue Implementation  

5.4 Sorting with User-Defined Comparisons  

5.5 Sorting with Alternative Algorithms  

5.6 Recursive Handling of Multidimensional Arrays  

5.7 Performing Set Operations on Arrays

5.8 Matrix Math Execution Using Arrays  

6   Functions  

6.1 Setting Optional Parameters  

6.2 Creating Recursive Functions  

6.3 Calling Functions Using a Function Name Stored in a Variable  

6.4 Dynamically Creating a Function (Lambda-Style)  

6.5 Using an Array of Functions for Processing  

6.6 Passing or Returning a Value by Reference  

6.7 Using an Arbitrary Number of Parameters  

6.8 Requiring a Parameter to Be a Certain Type  

7   Classes and Objects  

7.1 Automatically Loading Class Source Files  

7.2 Protecting Object Data (public/private/protected)  

7.3 Automatically Running Code On Creation or Destruction of an Object  

7.4 Accessing a Class’s Members Without Instantiation  

7.5 Extending a Class Definition  

7.6 Creating an Abstract Class  

7.7 Using Object Interfaces  

7.8 Dynamic and Overloaded Variable Names  

7.9 Overloading Methods  

7.10 Linked List Implementation  

7.11 Binary Tree Implementation  

8   Files and Directories  

8.1 Generating a Full Directory Listing  

8.2 Natural Display of File Sizes  

8.3 Renaming All Files Within a Directory  

8.4 Search for Filenames Within a Directory Tree  

8.5 Handling Relative and Absolute File Paths  

8.6 Reading a File Via HTTP or FTP  

8.7 Watching the Contents of a File As It Grows (Simulating UNIX tail -f)  

8.8 Generating a Difference Report Between Two Files  

8.9 Locking a File for Exclusive Use  

8.10 Caching Remote Files Locally  

8.11 Compressing and Uncompressing Files  

8.12 Automatically Including Certain Files from the Parent Tree  

Part II   Application

9   Web Page Creation/XHTML/CSS  

9.1 Creating a Multilayer Drop-Down Menu  

9.2 Highlighting What Section of a Website the User Is In  

9.3 Displaying Dynamic Progress Bars  

9.4 Simulating Graphical Charts with XHTML/CSS  

9.5 Pagination of Results on a Web Page  

9.6 Caching Web Page Output for Server Optimization  

9.7 Localizing a Web Page for Different Languages  

9.8 Using Ajax with PHP to Create an Interactive Web Page  

10   Web Form Handling  

10.1 Easily Obtaining Form Data  

10.2 Obtaining Multidimensional Arrays of Form Data  

10.3 Using GET and POST Form Data Together  

10.4 Accepting Uploaded Files  

10.5 Generating Select Statements  

10.6 Requiring Certain Fields to Be Filled Out  

10.7 Manipulating Text for Display on Bulletin Boards (BBCode)  

10.8 Accepting and Displaying User Data Giving Warnings for Links  

10.9 Preventing Multiple Form Submissions  

11   Data Validation and Standardization  

11.1 Phone Numbers  

11.2 ZIP Codes  

11.3 Social Security Numbers (SSNs)  

11.4 Numbers  

11.5 Credit Card Numbers  

11.6 Dates  

11.7 Email Accounts  

11.8 URLs  

12   Sessions and User Tracking  

12.1 Using Cookies to Remember Data  

12.2 Saving User Data with Sessions  

12.3 Customizing Display Settings for a User  

12.4 Creating a Library for Tracking a User Through Your Website  

12.5 Implementing a Simple Shopping Cart  

12.6 Passing Session Data Between Two Servers  

12.7 Parsing Specific Browser Information from Log Files  

13   Web Services and Other Protocols  

13.1 Submitting a POST HTTP Request with cURL  

13.2 Communicating with an LDAP Server  

13.3 Using Web Services Via SOAP  

13.4 Connecting to an FTP Server  

13.5 Creating a PHP-Based FTP Client  

13.6 Using Sockets to Connect to an Internet Server  

13.7 Creating Your Own Basic Web Server  

14   Relational Databases  

14.1 Communicating with MySQL  

14.2 Communicating with Oracle  

14.3 Communicating with PostgreSQL  

14.4 Communicating with Sybase  

14.5 Communicating with Microsoft SQL Server  

14.6 Communicating with SQLite  

14.7 Communicating with Databases Through ODBC  

14.8 Using an Abstraction Layer to Communicate with a Database (PDO)  

14.9 Implementing an SQLite Based Blog  

15   Other Data Storage Methods  

15.1 Creating and Reading CSV files  

15.2 Using Custom Text Files for Storage  

15.3 Accessing and Updating DBM-Style Databases  

15.4 Storing Data Via Serialize and Unserialize  

15.5 Automatically Creating and Updating PHP Include Files  

16   Email  

16.1 Sending Email (Text/HTML/Dual Format/Inline Images/Attachments)  

16.2 Determining Whether an Email Account Exists  

16.3 Creating a Mass Email Mailer  

16.4 Implementing Basic Mailing List Software  

16.5 Protecting Email Addresses from Spam Collectors  

16.6 Creating a Watchdog Process to Send Email If a Web Page Changes  

17   XML  

17.1 Parsing an XML File to Retrieve Data  

17.2 Performing Searches Through XML with XPath  

17.3 Validating an XML Document  

17.4 Transforming XML into XHTML with XSLT  

17.5 Creating an RSS File  

17.6 Creating an RSS Display Script for Websites  

18   Images  

18.1 Generating Composite Images with Text  

18.2 Drawing Tips and Tricks  

18.3 Using Transparent Backgrounds in Images  

18.4 Creating a Graph/Chart Library  

18.5 Automatically Creating a Photo Gallery from Digital Camera Files (Exif Data)  

19   Error Reporting and Debugging  

19.1 Defining a Custom Error Handler  

19.2 Using Exceptions to Handle Errors  

19.3 Timing the Execution of Your Script  

19.4 Using Shutdown Functions to Gracefully Handle Script Failures  

19.5 Generating Detailed Backtracing for Error Reporting  

20   User Authentication and Encryption  

20.1 Generating Random Passwords  

20.2 Using Encryption to Protect Data  

20.3 Simple CAPTCHA for Real User Detection  

20.4 Authenticating Users  

Part III   Appendixes

A   Migrating to PHP 5  

B   SPL  

C   Common PHP Error Messages