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, the course turns to database topics with several chapters on SQL basics followed by content on how to integrate PHP with the database. 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.
Create SQL Select, Insert, and Update statements.
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
- Single Quotes vs. Double Quotes
- Flow Control
- Conditional Processing
- If Conditions
- Loops
- while
- do…while
- for
- break and continue
- Arrays
- Enumurated Arrays
- Initializing Arrays
- Appending to an Array
- Reading from Arrays
- Looping through 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
- String Manipulation
- Concatenation
- String Manipulation Functions
- Examples of String Functions
- Magic Quotes
- magic_quotes_gpc
- magic_quotes_runtime
- Recommendation on Magic Quotes
- Reusing Code and Writing Functions
- Including Files
- require
- require_once
- include_path directive
- auto_prepend_file and auto_append_file
- User Functions
- Defining Calling Functions
- Default Values
- Variable Scope
- By Reference vs. By Value
- Form Processing
- Code Organization
- Simple SELECTs
- Introduction to the Northwind Database
- Comments
- Whitespace and Semi-colons
- Case Sensitivity
- SELECTing All Columns in All Rows
- SELECTing Specific Columns
- Sorting By a Single Column
- Sorting By Multiple Columns
- Sorting By Column Position
- Ascending and Descending Sorts
- The WHERE Clause and Operator Symbols
- Checking for Equality
- Checking for Inequality
- Checking for Greater or Less Than
- Checking for NULL
- WHERE and ORDER BY
- The WHERE Clause and Operator Words
- The BETWEEN Operator
- The IN Operator
- The LIKE Operator
- The NOT Operator
- AND
- OR
- Order of Evaluation
- Subqueries, Joins and Unions
- Subqueries
- Joins
- Table Aliases
- Multi-table Joins
- Outer Joins
- Unions
- UNION ALL
- UNION Rules
- Inserting, Updating and Deleting Records
- INSERT
- UPDATE
- DELETE
- Managing Data
- Querying a Database
- mysqli() Overview
- mysqli Methods and Properties
- Inserting and Updating Records
- 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
- Authentication with PHP and SQL
- A Database-less Login Form
- Regular Expressions
- 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
- Sending Email with PHP
- mail()
- Shortcomings of mail()
- PHPMailer
- 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