You are previewing PHP.
O'Reilly logo
PHP

Book Description

Master PHP in 20 lessons--online video tutorials included! Based on the author's successful online courses, this complete, integrated learning tool provides easy-to-follow lessons that feature clear explanations, sample code and exercises, and video tutorials. Each lesson is designed to take you less than an hour to complete. PHP: 20 Lessons to Successful Web Development covers the basics, including constants, superglobals, operators, and arrays. Next, you'l learn ow to work with multidimensional arrays, write unctions, manipulate objects, build web forms, anage security, use Ajax, and much more. ogether, the book and almost five hours of video training make learning PHP easier than ever! Ready-to-use code at www.mhprofessional.com

Table of Contents

  1. Cover
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. Acknowledgments
  8. Introduction
  9. Part I PHP Basics
    1. Lesson 1 Introduction to PHP
      1. A Little History
      2. Info for Programmers
      3. Why Is PHP so Popular?
      4. Downloading and Installing Web Browsers
      5. Choosing a Program Editor
      6. Installing a PHP Server
      7. Summary
      8. Self-Test Questions
    2. Lesson 2 Incorporating PHP into a Web Page
      1. Where to Place the PHP Code
        1. In the Document Head
        2. In the Document Body
        3. Including PHP Files
      2. Using Comments
      3. Using Semicolons
      4. Summary
      5. Self-Test Questions
    3. Lesson 3 Learning PHP Language Syntax
      1. Case Sensitivity
      2. Whitespace
      3. Variables
        1. Variable Naming
      4. String Variables
      5. Using Quotation Marks in Strings
        1. Using Heredoc Strings
      6. Escaping Characters
      7. Embedding Variables within a String
      8. Variable Typing and Casting
      9. Summary
      10. Self-Test Questions
    4. Lesson 4 Using Constants and Superglobals
      1. Using Constants
        1. Predefined Constants
        2. The echo and print Commands
      2. Superglobal Variables
        1. Superglobals and Security
      3. Other PHP Variables
      4. Summary
      5. Self-Test Questions
    5. Lesson 5 Working with Arithmetic Operators
      1. Arithmetic Operators
        1. Modulus
        2. Exponentiation
        3. Incrementing and Decrementing Variables
        4. Pre-Incrementing
        5. Post-Incrementing
        6. Pre- and Post-Decrementing
      2. Arithmetic Functions
      3. Assignment Operators
      4. Summary
      5. Self-Test Questions
    6. Lesson 6 Applying Comparison and Logical Operators
      1. Comparison Operators
      2. Logical Operators
        1. Exclusive Or
        2. Boolean Negation
      3. The Ternary Operator
      4. Bitwise Operators
      5. Operator Precedence
      6. Operator Associativity
      7. Summary
      8. Self-Test Questions
    7. Lesson 7 Creating Arrays
      1. Array Names
      2. Creating an Array
        1. Assigning Values to an Array Element
        2. Using Indexes
        3. Retrieving Values
        4. Using Array Elements as Indexes
        5. Other Ways of Creating Arrays
      3. Using Associative Arrays
        1. Keys, Values, and Hash Tables
        2. Other Ways of Creating an Associative Array
      4. Summary
      5. Self-Test Questions
    8. Lesson 8 Managing Multidimensional Arrays
      1. Creating a Two-Dimensional Array
      2. Accessing a Two-Dimensional Array
        1. A More Practical Example
      3. Multidimensional Associative Arrays
      4. Creating the Multidimensional Array
      5. Accessing the Arrays
      6. Summary
      7. Self-Test Questions
    9. Lesson 9 Calling Array Functions
      1. Using foreach()
      2. Using array_merge()
      3. Using implode()
      4. The array_walk() Function
      5. Using array_push()
      6. Using array_pop()
        1. Using array_push() and array_pop() Together
      7. Using array_reverse()
      8. The array_flip() Function
      9. Summary
      10. Self-Test Questions
    10. Lesson 10 Advanced Array Manipulation
      1. Using FILO and FIFO Arrays
        1. Buffering Using an Array
        2. Using array_unshift() and array_shift()
      2. Using sort()
        1. Reversing a Sort
      3. Using array_splice()
        1. Removing Elements from an Array
        2. Inserting Elements into an Array
        3. Advanced Array Splicing
      4. Summary
      5. Self-Test Questions
    11. Lesson 11 Controlling Program Flow
      1. The if() Construct
        1. Omitting the Braces
        2. Positioning of Braces
      2. The else Statement
      3. The elseif() Construct
      4. The switch() Statement
      5. Using the break Keyword
      6. Using the default Keyword
        1. Allowing Fall-Through
      7. Summary
      8. Self-Test Questions
    12. Lesson 12 Looping Sections of Code
      1. Using while() Loops
        1. The Example in Detail
      2. Using do … while() Loops
        1. The Example in Detail
      3. Using for() Loops
        1. The Example in Detail
      4. Breaking Out of a Loop
        1. Breaking Out of Multiple Loops
      5. The continue Statement
        1. Continuing within Multiple Loops
      6. Summary
      7. Self-Test Questions
  10. Part II Advanced PHP
    1. Lesson 13 Writing Functions
      1. Using Functions
        1. The return Statement
        2. Passing Arguments
        3. Accessing Arguments
        4. Handling Unknown Numbers of Arguments
      2. Global and Local Variable Scope
        1. Using Local Variables
      3. The $GLOBALS[] Superglobal Array
      4. Global Naming Convention
      5. Summary
      6. Self-Test Questions
    2. Lesson 14 Manipulating Objects
      1. OOP Terminology
      2. Declaring a Class
      3. Creating an Object
        1. Accessing Properties and Objects
      4. Using a Constructor
      5. Destructors
      6. Object Cloning
      7. Static Methods and Properties
      8. Predefined Properties
      9. OOP Constants
      10. Property and Method Scope
      11. Applying Inheritance
      12. Using the parent Keyword
      13. Writing Subclass Constructors
      14. Using the final Keyword
      15. Summary
      16. Self-Test Questions
    3. Lesson 15 Handling Errors and Expressions
      1. Error Trapping
      2. Regular Expressions
        1. Using preg_match()
        2. Using preg_match_all()
        3. Using preg_replace()
      3. Fuzzy Matching
        1. Matching Any Character
        2. Not Matching a Character
      4. Summary
      5. Self-Test Questions
    4. Lesson 16 Building Web Forms
      1. Creating a Form
        1. The Difference Between Post and Get Requests
        2. Security Issues with Get Requests
        3. Accessing Form Data from PHP
        4. About register_globals
      2. Redisplaying a Form
        1. The checkbox and select multiple Input Types
        2. Using Hidden Fields
      3. Summary
      4. Self-Test Questions
    5. Lesson 17 Maintaining Security
      1. Sanitizing Input
      2. Uploading Files to a Server
        1. The $_FILES[] Array
        2. File Security
      3. Other Potential Insecurities
      4. Summary
      5. Self-Test Questions
    6. Lesson 18 Accessing Cookies and Files
      1. Using Cookies
        1. Setting a Cookie
        2. Reading a Cookie
        3. Deleting a Cookie
        4. Combining These Three Functions
      2. Browser Identification
        1. The GetBrowser() Function
      3. File Handling
        1. Testing for a File Existing
        2. Creating or Opening a File
        3. Writing to a File
        4. Closing a File
        5. Reading from a File
      4. Summary
      5. Self-Test Questions
    7. Lesson 19 Advanced File Handling
      1. Combining File Functions
      2. Saving Any Form Data
        1. Reading from the Data File
        2. Prepopulating the Shopping List
        3. The HTML Section
      3. Even Simpler File Accessing
      4. File Copying
      5. File Deleting
      6. File Moving
      7. Random Access
        1. Writing to a Random Access File
      8. Managing Directories
      9. File Locking
        1. A Practical Example
      10. Summary
      11. Self-Test Questions
    8. Lesson 20 Authentication, Sessions, and Ajax
      1. Authentication
      2. Using Sessions
        1. Retrieving Session Variables
        2. Combining Authentication with Sessions
        3. Picking Up Session Details
        4. Closing a Session
        5. Session Security
      3. Using Ajax
      4. Creating an Ajax Object
      5. The PostAjaxRequest() Function
      6. The GetAjaxRequest() Function
      7. The callback() Function
      8. The ajax.php Program
      9. Summary
      10. Self-Test Questions
  11. Appendix Answers to the Self-Test Questions
    1. Lesson 1 Answers
    2. Lesson 2 Answers
    3. Lesson 3 Answers
    4. Lesson 4 Answers
    5. Lesson 5 Answers
    6. Lesson 6 Answers
    7. Lesson 7 Answers
    8. Lesson 8 Answers
    9. Lesson 9 Answers
    10. Lesson 10 Answers
    11. Lesson 11 Answers
    12. Lesson 12 Answers
    13. Lesson 13 Answers
    14. Lesson 14 Answers
    15. Lesson 15 Answers
    16. Lesson 16 Answers
    17. Lesson 17 Answers
    18. Lesson 18 Answers
    19. Lesson 19 Answers
    20. Lesson 20 Answers
  12. Index