PHP Advanced Class

ActiveState logo This advanced PHP training is targeted at PHP developers who can create dynamic, data-driven web sites, but don't know how to take advantage of PHP's advanced features like object-oriented programming, PEAR modules, frameworks and more.

Through lecture and hands-on exercises we illustrate these topics in our PHP course. In this advanced PHP training course, you will learn how to:

Advanced Functions in PHP

You are probably familiar with creating simple functions to call from your PHP scripts. There are several additional features PHP offers to make functions more powerful. We teach you these features, including how to:

  • Define global variables
  • Assign default values to arguments
  • Pass variables by reference
  • Retrieving a variable-length list of arguments

Serializing Data for Persistence

Storing numbers and text in a database is fine, but what if you have to store a data structure, like a shopping cart, in a database for future retrieval? If you've ever opened a PHP session data file in a text editor, you see that data structures such as arrays and hashes can be stored as strings that look like: a:1:{s:10:"productSKU";s:6:"SBCD12";}. These are "serialized" variables that have been expanded from an array or other data structure into a string. We show you how to take such complex data structures and turn them into strings that can be stored in a database or a session variable, including how to:

  • Use the serialize() function in conjunction with unserialize()
  • Tell from the serialized string what the variable contains

Pattern-matching with PHP

PHP borrowed one of the most popular features of another programming language, Perl, to provide a facility for developers to match patterns in strings. Using "regular expressions" (pattern definitions), you can process text files or remote web pages to scrape email addresses, SKUs, prices, or almost any other bit of text that matches an identifiable pattern. We cover how to:

  • Define regular expressions using symbols such as [a-z], \d, and "."
  • Find patterns with preg_match() and ereg_match()
  • Replace patterns you've found with preg_replace()
  • Find one or more instances of a pattern
  • Conceptualize and effectively use the pattern of zero or more instances of a pattern

Object Oriented Programming and PHP

OOP (Object Oriented Programming) is the dominant paradigm in languages such as Java, C++, Python and Ruby; PHP has its own OOP implementation. In object-oriented programming, your application environment is composed of objects belonging to "classes" and each object has various properties and functions.

If you think the Asteroids game as an object-oriented programming, it's easy to see how you could have a class of rocks with individual rock objects as instances of that class, as well as other objects for ships, missiles, and aliens; each object has its own set of properties, such as speed, direction, or color; and each object has various functions, such as flying, exploding, or splitting into smaller objects.

PHP has features for creating class definitions, instantiating new objects, assigning properties, and calling functions (also known as "methods"). We train you in how to:

  • Define classes with associated methods and properties
  • Instantiate objects belonging to those classes, establish their properties and call their methods
  • Know when to use the "public," "private," "protected," "self," "this," and "::" keywords
  • Create static member functions, constants and variables
  • Extend your classes and override methods to create slightly modified objects based on existing classes (e.g., "Comet" extends "Asteroid") with the same flying method but its "explode" method might work differently

PEAR Packages in PHP

PEAR (PHP Extension and Application Repository) is an online database of PHP components to use in your PHP scripts. Whether you need parse XML, encrypt data, dynamically create a chart, or bar code, there is a PEAR package to do it, available from Installing and using these modules requires some knowledge of the PEAR system. Our training covers how to:

  • Install and configure the PEAR Package Manager
  • Find PEAR packages and see their documentation
  • Install PEAR packages and use them in your PHP scripts

PHP Frameworks: CakePHP, Symfony, & Zend Framework

Since web programmers typically face the same tasks in different web sites (e.g., shopping carts, login/logouts, data drilldowns, etc.) various "rapid development frameworks" have appeared that lend themselves to creating these types of features. Frameworks are sets of PHP pages that give you a consistent set of PHP objects that easily adapt to the most common tasks faced by web programmers; another feature of modern frameworks is a set of conventions on naming database tables and fields so PHP can make valid assumptions about data requests without having the programmer spell everything out each time the PHP script interacts with the database. In the advanced PHP class, we explore the differences between three popular PHP Frameworks. We focus on the CakePHP framework and cover how to:

  • Install and configure the CakePHP, Symfony, and Zend frameworks
  • Understand the CakePHP framework folder structures
  • Set up Models, Views, and Controllers in CakePHP
  • Instantiate objects from framework classes and call their methods in CakePHP

Popular PHP Applications: Drupal, Joomla, & Wordpress

Some of the most popular open source web applications are written in PHP, and among these, the most popular are content management systems (CMS). A CMS allows you to manage a web site without through a web interface, generally without having to edit the source code. We explore the differences between three popular CMSs (Drupal, Joomla, and Wordpress). We focus on Wordpress, covering how to:

  • Install the Drupal, Joomla, and WordPress CMSs
  • Create and edit web pages in WordPress
  • Understand the relevant parts of the WordPress PHP source code
  • Identify the database model that underlies the WordPress CMS


  • Ability to create a data-driven PHP web site

Advanced PHP classes offered at four locations: