PHP Classes in PacMass DevelopmentΒΆ

PHP has complete Object Oriented Programming support, and using PHP classes are a useful way to create powerful web applications. In the case of PacMass, the site uses classes to handle repeated, shared functions throughout the site.

For example, for the validation on the server-side, a PHP class is used:

class Validation {

    // Check for topic choice
    pubic function check_topic($field) {

        if ($field == 'default_option') {
            $error = "Please select a topic.<br />";
            return $error;
        }

        else {
            $error = '';
            return $error;
        }
    }

    . . . // more functions

}

This makes writting code quicker, and these classes can be used throughout the site. Other classes include Utility, Naviagtion, etc. Each class has a set of functionality that can be used to do work. The format to use these classes in the site code might look like this:

require_once($includes_dir . $ds . 'Navigation.php');
$navigation = new Navigation();
$navigation -> print_navigation($image_dir, $ds, $page_nav_dk, $page_nav_lt);

This would create an instance of the Navigation class and then run it’s print_navigation method with the arguments supplied as PHP variables.