__autoload helper class


/ Published in: PHP
Save to your folder(s)

You know how to use it when you see the code, very simple. Just use files() method.
Example:

function __autoload($class)
{
$files = fuselogic_autoload::files($class);
foreach($files as $file)
{
if(@include_once($file)) break;
}
}


Copy this code and paste it in your HTML
  1. class fuselogic_autoload
  2. {
  3. function find1($class = null)
  4. {
  5. // 'class_name' -> 'class.class_name.php';
  6. return strtolower('class.'.$class.'.php');
  7. }
  8.  
  9. function find2($class = null)
  10. {
  11. // 'ClassName' -> 'class.class_name.php';
  12. $return = strtolower(preg_replace('/[A-Z]/','_$0',$class));
  13. $return = str_replace('_____','','____'.$return.'____');
  14. $return = str_replace('____','',$return);
  15. $return = 'class.'.$return.'.php';
  16. return $return;
  17. }
  18.  
  19. function files($class = null)
  20. {
  21. $return[] = fuselogic_autoload::find1($class);
  22. $return[] = fuselogic_autoload::find2($class);
  23. return $return;
  24. }
  25. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.