In this intensive, hands-on PHP training course, students will learn to create database-driven websites using PHP and MySQL®. Students will first learn the basics of PHP including syntax, flow control, string manipulation, and functions. Next, they will learn to integrate PHP with the database, both directly, as well as through the PEAR DB package. Regular Expressions are covered next to give students the tools they need for advanced form validation. Then, students will learn to track users as they move from page to page within a web site using PHP session variables. Finally, they will learn to manipulate files and send emails using built-in PHP functions.
Objectives
Write PHP scripts using all the major features of the language.
Control the flow of program execution.
Use indexed and associative arrays to store sets of values.
Process and validate HTML forms.
Work with PHP’s built-in string manipulation functions.
Write reusable files and include them in multiple pages.
Define functions to create more manageable PHP applications.
Integrate PHP with a database to create reports and insert and update records.
Use the PEAR DB package as a database abstraction layer.
Use PHP regular expressions for advanced form validation.
Use session variables to create site-wide user authentication and cookies to remember visitors between visits.
Send email with PHP’s built in mail() function.
Read, write, and upload files.
Detailed Outline
- PHP Basics
- How PHP Works
- The php.ini File
- PHP Tags
- PHP Statements and Whitespace
- Comments
- PHP Functions
- Variable Types
- Variable Names (Identifiers)
- Type Strength
- Variable Scope
- Superglobals
- Constants
- Variable Testing and Manipulation Functions
- PHP Operators
- Creating Dynamic Pages
- Single Quotes vs. Double Quotes
- Passing Variables on the URL
- Flow Control
- Conditional Processing
- Working with Conditions
- Types of Loops
- Working with Loops
- Arrays
- Enumerated Arrays
- Initializing Arrays
- Appending to an Array
- Reading from Arrays
- Associative Arrays
- Initializing Associative Arrays
- Reading from Associative Arrays
- Looping through Associative Arrays
- Superglobal Arrays
- Two-dimensional Arrays
- Reading from Two-dimensional Arrays
- Looping through Two-dimensional Arrays
- Array Manipulation Functions
- PHP and HTML Forms
- How HTML Forms Work
- A Sample HTML Form
- Form Variables
- Processing Form Input
- String Manipulation
- Concatenation
- String Manipulation Functions
- Magic Quotes
- magic_quotes_gpc
- magic_quotes_runtime
- Reusing Code and Writing Functions
- Including Files
- require
- require_once
- include_path directive
- auto_prepend_file and auto_append_file
- Adding a Header and Footer
- User Functions
- Defining Calling Functions
- Default Values
- Variable Scope
- By Reference vs. By Value
- Form Processing
- Form Validation & Presentation Functions
- Managing Data
- Querying a Database
- mysqli() Overview
- mysqli Methods and Properties
- mysqli Prepared Statements
- MDB2
- Advantages and Disadvantages of MDB2
- Why use a database abstraction layer?
- When not to use a database abstraction layer?
- Using MDB2
- Creating a Customer Report
- Authentication with PHP and SQL
- A Database-less Login Form
- Authenticating Users
- Regular Expressions
- Perl-compatible Regular Expression Functions
- preg_match()
- preg_replace()
- Regular Expression Tester
- Regular Expression Syntax
- Start and End ( ^ $ )
- Number of Occurrences ( ? + * {} )
- Common Characters (. \d \D \w \W \s \S)
- Grouping ( [] )
- Negation ( ^ )
- Subpatterns ( () )
- Alternatives ( | )
- Escape Character ( \ )
- Form Validation Functions with Regular Expressions
- Session Control and Cookies
- Sessions
- Configuring Sessions
- Session Functions
- Cookies
- Authentication with Session Control
- Sending Email with PHP
- mail()
- Shortcomings of mail()
- PHPMailer
- Sending a Password by Email
- File System Management
- Opening a File
- Reading from a File
- Writing to a File
- File Locking
- Uploading Files via an HTML Form
- Getting File Information
- More File Functions
- Directory Functions
- Getting a Directory Listing
- Creating a Resume Management Page