Jump to content

tklawsuc

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tklawsuc's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I hope I am posting this in the right place. I have a PHP4 application that has 50+ classes (some custom some 3rd party). One of the things I wanted to implement was something like the __autoload in php5. Can I get some feedback on the performance/efficiency/effectiveness of the following attempt to have an autoload class? class Loader { var $paths = array(); //classes’ paths function Loader() { //specify all our classes and where they can be found either relative to Loader or absolute path $paths['Class1'] = 'Class1.class.php’; $paths['Class2'] = '/absolute_path/Class2.class.php’; // … } //load the class file if not yet loaded and return a reference to the requested instance function &load($class) { if (!class_exists($class)) require($paths[$class]); $inst =& new $class; return $inst; } } $App =& new Loader(); $inst1 = $App->load('Class1'); inst2 = $App->load('Class2');
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.