Posted By

ekobudisetiyo on 07/12/06


Tagged

php5 autoload


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

mate
nicolaspar


__autoload helper class


 / Published in: PHP
 

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

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

  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  

You need to login to post a comment.