Lazy load class in PHP

php

Solution

Change `Employee` a bit:

class Employee {

   public static function __autoload($class) {
      //_once is not needed because this is only called once per class anyway,
      //unless it fails.
      require $class;
   }

   /* Other methods Omitted */
}
spl_autoload_register('Employee::__autoload');

Problem

I want to lazy load class but with no success ``` <?php class Employee{ function __autoload($class){ require_once($class); } function display(){ $obj = new employeeModel(); $obj->printSomthing(); } } ``` Now when I make this ``` function display(){ require_once('emplpyeeModel.php'); $obj = new employeeModel(); $obj->printSomthing(); } ``` It works but I want to lazy load the class.

Original source