A PHP course designed to enable web developers and others with limited programming experience to build dynamic database driven e-commerce web sites using the PHP programming language.

Since PHP is such a rich and task-specific language, the course covers the most important range of functions in depth, and equips delegates to understand the remaining less essential aspects.

The contents of this PHP course are identical to our three day in-house "PHP for Programmers" course, but the pacing is adjusted to suit the needs of public delegates and non-programmers.

PHP is Open Source and Cross Platform, running on Unix, Linux, MS Windows, Apple Mac, AS/400 and more, and is often used with an OS-CP database and web server such as MySql and Apache. Thus PHP will work on the operating system and hardware that currently suits your applications and organisation. PHP is a ''P'' in the LAMP stack. PHP 5 is the current version of PHP and is what the course teaches.

Differences with PHP 4 are explained for those who need to maintain legacy code. There is also a look forwards to the features expected in PHP 6. MySQL 5 is the primary database that is used, the course also covers Oracle and MS-SQL. Delegates should have few problems transferring their learned skills to interacting to other databases with PHP.

The last day of the course is taken producing a complete database driven application. An application skeleton is provided (and can be taken away) which makes for a quick start.

There are short reviews including: Apache configuration, SQL (SELECT, JOIN & WHERE). Delegates are shown how to: manage test and production sites (configuration, copying, avoiding confusion as to which is which). A complete sample solution is given to the delegates.

This is a hands-on practical workshop based around the development of fully working PHP website services. Strong emphasis is laid on practical examples for which a range of worked solutions are made available.

Suitable For:

Web developers and web designers with a modest amount of programming experience.
Students will typically have used another simple or domain-specific language such as VBscript or Javascript


A basic working knowledge of HTML is presumed.
Some conceptual knowledge of how web servers and web browsers (clients)interact using HTTP
A working knowledge of at least one scripting/programming language or evidence of strong capabilities in relevant areas of mathematical/logical reasoning

Course Outline

Introduction to PHP

  • History of PHP
  • Comparison with dynamic content alternatives (Perl, CGI, ASP, JSP, Servlets , CGI, etc)
  • PHP tools and set up (web browser/server, editor, libraries, etc)
  • Create a basic PHP Script
  • Opening and Closing tags
  • PHP as a command line or batch language
  • Taking user input (HTML forms)
  • Self Referring Forms
  • Selecting alternatives
  • Use PHP to generate HTTP headers
  • Generating HTTP redirects
  • Pass PHP variables via the URL
  • Debugging Tips
  • Where to find PHP documentation

Taking User Input from Forms via PHP

  • Creating forms with PHP
  • Security Protection from Cross Site Scripting
  • Using the form GET method
  • Using the form POST method
  • Obtaining data from forms through variables $_REQUEST, $_POST or $_GET ?
  • Using hidden fields
  • Secure Web Forms (HTTPS and SSL)
  • Calling pages from themselves using forms
  • Quoting HTML entities in user input

Variables and Expressions in PHP

  • Identifiers
  • Data Types (integers, floats, strings and booleans)
  • Type juggling
  • Text constants, interpolation (strings, arrays, objects, functions), here & now documents
  • Creating Variables
  • Variable assignment
  • Variable Scope
  • Namespaces
  • User-defined Constants
  • String constants, variable interpolation into strings
  • Array, Object & Function interpolation
  • HTTP environment variables
  • Magic Constants GLOBALS array
  • Variable References

PHP Operators

  • Arithmetic Operators
  • Logical Operators
  • Relational (Comparison) Operators
  • The Identity Operator
  • The Assignment Operators
  • Increment & Decrement Operators
  • Bitwise Operators
  • Error Suppression Operator
  • The Conditional (Ternary) Operator
  • The Default Operator
  • Execution Operators
  • Other Operators
  • Assignment Operators
  • Operator Precedence and Associativity

Conditional Tests and Events in PHP

  • True and False if
  • Comparing Strings and Numbers else and elseif
  • Hierarchical conditions (nested if statements)
  • The ? : Operator
  • Comparing for equality or identity
  • The switch / case statement
  • Alternative Syntax for Control Structures

PHP Flow Control

  • Loops while do ... while for break and continue goto exit

PHP Configuration

  • The php.ini file
  • Module Vs CGI Usage register_globals
  • Control of error logging
  • Control of resource limits
  • Commonly set configurations
  • File system security safe_mode & open_basedir
  • PHP4 compatibility in PHP5
  • A glance at upcoming PHP6

PHP Functions

  • Purpose of functions
  • Built-in functions
  • Declaring functions
  • Functions Arguments
  • Default Arguments
  • Arguments - Call by Reference
  • Return
  • Returning References
  • Variable Scope (global vs local)
  • Static variables
  • Recursion include and require
  • Variable function calls

Storing Data in Arrays using PHP

  • What are arrays?
  • How and when to use arrays
  • Indexing arrays, numeric and hashes
  • Initialising arrays
  • Using foreach
  • Add/remove elements from arrays
  • One-dimensional arrays
  • Multi-dimensional arrays
  • References to array elements
  • Arrays in forms
  • Array operators
  • Array related functions


Handling Databases with PHP

  • PHP's database APIs
  • Error-handling strategies
  • Connection/disconnection to the database, log in/log out
  • Escaping strings in SQL statements
  • Including common access functions
  • Doing simple SQL queries via PHP
  • Building HTML tables using SQL Queries
  • Avoiding SQL Injection attacks
  • Access to: MySql, MySqli, Oracle & MS-SQL
  • Using PEAR DB
  • Using PHP Data Objects - PDO
  • An Insight to Smart Programming

String Manipulation in PHP

  • Substring and [] operators
  • Case conversion, trimming
  • Formatting output data with sprintf
  • Adding & removing backslashes
  • Regular expressions
  • Metacharacters: character classes, repetitions
  • Regular Expression Examples
  • Alternation and Grouping
  • Perl Compatible Regular Expressions PCRE
  • Capturing for Enhanced Validation
  • Substitution with PCRE preg_split and Regexes
  • Deprecation of POSIX Extended Library
  • Web Site Vulnerabilities

Sessions and Cookies in PHP

  • What is a session?
  • Dependencies on the php.ini file
  • Understanding PHP session variables
  • Create a PHP session variable
  • Register and modify PHP session variables
  • Putting PHP session IDs in pages
  • Good Practise with sessions and PHP
  • Cookie properties
  • Setting a cookie in PHP
  • Retrieving PHP cookies
  • Expiring/Deleting PHP cookies
  • Drawbacks to cookies
  • Using cookies well
  • Testing for cookie support
  • Sessions without cookies
  • Cookie Security Issues

File and Directory Access Using PHP

  • Opening files, local and remote
  • Reading & writing and moving about in files fflush(), file(), fpassthru(), readfile()
  • PHP portability on different Operating Systems
  • Finding file metadata: size, ownership, modification time
  • Handling file permissions
  • Handling file ownership
  • Copying, Renaming and Deleting Files
  • File locking
  • Opening and reading directories
  • File uploads from the browser/user

Other I/O Issues in PHP

  • Getting IP addresses from visitors
  • Getting referring URLs from visitors
  • Environment variables
  • Showing different content to different browsers (IE, Netscape, Firefox, Mozilla, Opera, etc)
  • Handling HTTP and MIME headers

Object Orientation in PHP

  • Object basics
  • Classes in PHP
  • PHP4 - constructors
  • PHP5 - constructors and destructors
  • Inheritance
  • Accessing instance data and functions __sleep and __wakeup __autoload
  • Class constants
  • PHP5 OO Additions, type hints, foreach, __autoload
  • PHP 5.4 — instantiate & member access
  • Objects: Assignments and References try, throw catch exception handling

PEAR, PECL and Smarty

  • PECL quick tour
  • APC - Alternative PHP Cache
  • Xdebug - debugging and profiling
  • PEAR installation and quick tour
  • PEAR Config
  • PEAR Log
  • PEAR Auth (login)
  • PEAR HTML_QuickForm2
  • Smarty Templates
  • Smarty and HTML_QuickForm2
  • Smarty and QuickForm2 help with security

Handling Email with PHP

  • Sending email
  • Sending multi part email - MIME
  • Accessing mail boxes - IMAP & POP

Graphics in PHP

  • Graphics basics, referencing a PHP scrip in an IMG tag
  • Image MIME type
  • Basic examples, line/box drawing
  • Creation from an existing image
  • Image copying and resizing
  • Drawing text on images
  • True Type fonts

Putting it all together — outline

  • Application design
  • Quick start
  • Web server configuration
  • Apache Virtualhost config
  • Simple project — 2 table database
  • Project skeleton
  • Configuration: test & live sites
  • Structure of web program
  • Smarty templates for the project
  • Structure of a Smarty template
  • Example Smarty template
  • Firefox Add-ons: Web Developer, Firebug, YSlow
  • Using rsync to copy test to live

Putting it all together — database

  • The database behind the application
  • Designing the database
  • Metadata management
  • Entity-relationship (ER) diagrams
  • ER Diagram example
  • Data Modelling tools
  • Users to access the database
  • Creating the databases & tables
  • Creating test data

Putting it all together — displaying data

  • Displaying data from the database
  • Outline of data display function
  • Example list display function
  • Displaying a list with Smarty
  • More succinct use of SQL
  • SQL WHERE clauses
  • Combine tests in a WHERE clause
  • SQL: grouping and Ordering of results
  • Displaying long lists in pages with LIMIT
  • Showing lists a page at a time
  • Implementing pages in Smarty Templates
  • Making Smarty and SQL play well
  • Summary

Acting on items in a list

  • Choosing items from a list
  • Big picture
  • Multiple items chosen at once
  • One item only to be chosen
  • One item with select action onChange: auto submit the form
  • Greying out options
  • Searching in a list
  • What to do with something chosen
  • Conclusion

Create & edit data

  • Creating & editing data
  • Creating & editing are much the same
  • Use the same names everywhere
  • outline use of a HTML_QuickForm2 form
  • Adding fields to the form
  • Field validation
  • Validation types
  • Smarty Template with HTML_QuickForm2
  • Form validation and processing
  • Display of validation errors
  • Conclusion

Putting it all together — conclusion

  • Other issues
  • Version control
  • Audit trail
  • security and access control
  • Performance
  • Styling and accessibility



"Private Training Institute has sucessfully taught my son C++ programming from scratch and he is now writing his own programs."
Antoinette Franco


"Your tutors successfully taught 3 of our car company staff how to use Excel and Outlook. Very happy with your services."
Seuntjie Botha