corporalelectric
11/10/2016 - 2:53 PM

PHP Autoload

PHP Autoload

function myAutoloadFunction($classname) {
    if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $classname)) {
      //check for valid classname
      require_once "/path/to/classes/$classname.php";
    }
  }

spl_autoload_register('myAutoloadFunction');