You are previewing PHP and MySQL™ Phrasebook.
O'Reilly logo
PHP and MySQL™ Phrasebook

Book Description

PHP and MySQL Phrasebook gives you the code you need to  complete your web programming projects quickly and effectively in PHP, the leading scripting language for creating dynamic web pages.

Concise and Accessible

Easy to carry and easy to use–lets you ditch all those bulky books for one portable pocket guide

Flexible and Functional

Packed with more than 100 customizable code snippets–so you can readily code functional PHP and MySQL in just about any situation

Table of Contents

  1. Title Page
  2. Copyright Page
  3. Table of Contents
  4. About the Author
  5. We Want to Hear from You!
  6. Reader Services
  7. Introduction
    1. Introduction for the Second Edition
  8. 1. Manipulating Strings
    1. Comparing Strings
    2. Checking Usernames and Passwords
    3. Converting Strings into HTML
    4. Using Line Breaks
    5. Encrypting Strings
    6. Checksumming Strings
    7. Extracting Substrings
    8. Protecting Email Addresses Using ASCII Codes
    9. Scanning Formatted Strings
    10. Getting Detailed Information about Variables
    11. Searching in Strings
    12. Using Perl-Compatible Regular Expressions
    13. Finding Tags with Regular Expressions
    14. Validating Mandatory Input
    15. Validating Email Addresses
    16. Search and Replace
  9. 2. Working with Arrays
    1. Accessing All Elements of Numeric Arrays
    2. Accessing All Elements of Associative Arrays
    3. Accessing All Array Elements in Nested Arrays
    4. Turning an Array into Variables
    5. Converting Strings to Arrays
    6. Converting Arrays to Strings
    7. Sorting Arrays Alphabetically
    8. Sorting Associative Arrays Alphabetically
    9. Sorting Nested Arrays
    10. Sorting Nested Associative Arrays
    11. Sorting IP Addresses (as a Human Would)
    12. Sorting Anything
    13. Sorting with Foreign Languages
    14. Applying an Effect to All Array Elements
    15. Filtering Arrays
    16. Getting Random Elements Out of Arrays
    17. Making Objects Behave Like Arrays
  10. 3. Date and Time
    1. Using Text within date()
    2. Formatting DateTime Objects
    3. Automatically Localizing Dates
    4. Manually Localizing Dates
    5. Using the Current Date, the U.S./U.K./European Way
    6. Formatting a Specific Date
    7. Validating a Date
    8. Calculating a Relative Date
    9. Creating a Sortable Time Stamp
    10. Converting a String into a Date
    11. Determining Sunrise and Sunset
    12. Using Date and Time for Benchmarks
    13. Using Form Fields for Date Selection
    14. Create Self-Updating Form Fields for Date Selection
    15. Calculating the Difference between Two Dates
    16. Using GMT Date/Time Information
  11. 4. Working with Objects (and Related Topics)
    1. Setting Up Classes
    2. Understanding Inheritance
    3. Using Abstract Classes and Interfaces
    4. Preventing Inheritance and Overwriting
    5. Using Autoloading
    6. Cloning Objects
    7. Serializing and Deserializing Objects
    8. Implementing Singletons
    9. Using Traits
  12. 5. Interacting with Web Forms
    1. Sending Form Data Back to the Current Script
    2. Reading Out Form Data
    3. Checking Whether a Form Has Been Submitted
    4. Saving Form Data into a Cookie
    5. Prefilling Text Fields and Password Fields
    6. Prefilling Multiline Text Fields
    7. Preselecting Radio Buttons
    8. Preselecting Check Boxes
    9. Preselecting Selection Lists
    10. Preselecting Multiple Selection Lists
    11. Processing Graphical Submit Buttons
    12. Checking Mandatory Fields
    13. Checking Selection Lists
    14. Escaping Output
    15. Validating Input
    16. Writing All Form Data into a File
    17. Sending All Form Data via Email
    18. Getting Information about File Uploads
    19. Moving Uploaded Files to a Safe Location
    20. Monitoring the Progress of a File Upload
  13. 6. Remembering Users (Cookies and Sessions)
    1. Understanding Cookies
    2. Creating a Cookie
    3. Reading Out Cookies
    4. Setting a (Reasonable) Expiry Date
    5. Setting a Client-Specific Expiry Date
    6. Deleting a Cookie
    7. Making Cookies Accessible for Several Domains
    8. Checking Whether the Client Supports Cookies
    9. Saving Multiple Data in One Cookie
    10. Saving the User’s Language Preference
    11. Understanding Sessions
    12. Where to Store the Sessions
    13. How to Maintain the Session State
    14. Activating Sessions
    15. Reading and Writing Sessions
    16. Closing Sessions
    17. Changing the Session ID
    18. Implementing a Custom Session Management
    19. Creating a Secured Area with Sessions
    20. Creating a Secured Area without Sessions
  14. 7. Using Files on the Server File System
    1. Opening and Closing Files
    2. Reading from Files
    3. Writing to Files
    4. Locking Files
    5. Using Relative Paths for File Access
    6. Avoiding Security Traps with File Access
    7. Working with CSV Data
    8. Parsing INI Files
    9. Retrieving File Information
    10. Copying, Moving, and Deleting Files
    11. Browsing the File System
    12. Using PHP Streams
    13. Using Bzip2 Archives
    14. Returning Files with an HTTP Request
  15. 8. Working with MySQL Databases
    1. Connecting to MySQLi
    2. Sending SQL to MySQL
    3. Prepared Statements with MySQL
    4. Retrieving Results of a Query to MySQL
    5. Retrieving the Last Inserted ID
    6. Using Transactions
  16. 9. Working with Other Databases
    1. Connecting to SQLite
    2. Sending SQL to SQLite
    3. Retrieving Results of a Query to SQLite
    4. Using Prepared Statements with SQLite
    5. Connecting to PostgreSQL
    6. Sending SQL to PostgreSQL
    7. Updating Data in PostgreSQL
    8. Retrieving Results of a Query to PostgreSQL
    9. Connecting to Oracle
    10. Sending SQL to Oracle
    11. Retrieving Results of a Query to Oracle
    12. Connecting to MSSQL
    13. Sending SQL to MSSQL
    14. Retrieving Results of a Query to MSSQL
    15. Using Prepared Statements with MSSQL
    16. Using MSSQL without Windows
    17. Connecting to Firebird
    18. Sending SQL to Firebird
    19. Retrieving Results of a Query to Firebird
    20. Connecting via PDO
    21. Sending SQL via PDO
    22. Retrieving Results of a Query via PDO
  17. 10. Using XML
    1. Parsing XML with SAX
    2. Parsing XML with XMLReader
    3. Using DOM to Read XML
    4. Using DOM to Write XML
    5. Using XMLWriter to Write XML
    6. Using SimpleXML
    7. Using XPath with SimpleXML
    8. Transforming XML with XSL
    9. Validating XML
  18. 11. Communicating with Others
    1. Connecting with HTTP Servers
    2. Connecting with FTP Servers
    3. Checking Whether a Server Is Still Reacting
    4. Creating a Web Service with NuSOAP
    5. Automatically Generating WSDL with NuSOAP
    6. Consuming a Web Service with NuSOAP
    7. Creating a Web Service with the PHP 5 SOAP Extension
    8. Consuming a Web Service with the PHP 5 SOAP Extension
    9. Using Ajax
    10. Exchanging Data with the Server
  19. Index