PHP Classes

File: demo.php

Recommend this page to a friend!
  Classes of Roy Yu   Object dynamic generation   demo.php   Download  
File: demo.php
Role: Example script
Content type: text/plain
Description: Entry points of this demo, show how to use the classes
Class: Object dynamic generation
Create model classes dynamically
Author: By
Last change: -- change includes path
Date: 14 years ago
Size: 844 bytes


Class file image Download
 * This is the demo page.
 * It shows how to dynamically create objects on the fly in
 * different ways.
 * @author Roy
spl_autoload_register(array('Factory', 'autoload'));

//This array is the $title, $price, $category of Movie
$param1 = array('Little Prince', 100, 'Children');

// ArrayList shows how to use SPL
$movies = new ArrayList();
// different ways to create Movie object
$movies->add(Factory::create('Movie', $param1));
$movies->add(new Movie('Fast and Furious', 25, 'PG 13'));
     * Movie object does not contain any GETTER
     * Those functions are generated on the fly
foreach($movies as $movie) {
$movie->getTitle().'<br />';
} catch(
Exception $e) {
print_r('<b>Error: </b>'.$e->getMessage());