Return to Snippet

Revision: 379
at July 12, 2006 05:35 by ekobudisetiyo


Updated Code
class fuselogic_autoload
{
   function find1($class = null)
   {
      // 'class_name' -> 'class.class_name.php';
      return strtolower('class.'.$class.'.php');
   }

   function find2($class = null)
   {
      // 'ClassName' -> 'class.class_name.php';
      $return = strtolower(preg_replace('/[A-Z]/','_$0',$class));
      $return = str_replace('_____','','____'.$return.'____');
      $return = str_replace('____','',$return);
      $return = 'class.'.$return.'.php';
      return $return;
   }

   function files($class = null)
   {
      $return[] = fuselogic_autoload::find1($class);
      $return[] = fuselogic_autoload::find2($class);
      return $return;
   }
}

Revision: 378
at July 12, 2006 05:34 by ekobudisetiyo


Initial Code
<?php
class fuselogic_autoload
{
   function find1($class = null)
   {
      // 'class_name' -> 'class.class_name.php';
      return strtolower('class.'.$class.'.php');
   }

   function find2($class = null)
   {
      // 'ClassName' -> 'class.class_name.php';
      $return = strtolower(preg_replace('/[A-Z]/','_$0',$class));
      $return = str_replace('_____','','____'.$return.'____');
      $return = str_replace('____','',$return);
      $return = 'class.'.$return.'.php';
      return $return;
   }

   function files($class = null)
   {
      $return[] = fuselogic_autoload::find1($class);
      $return[] = fuselogic_autoload::find2($class);
      return $return;
   }
}
?>

Initial URL

                                

Initial Description
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;
   }
}

Initial Title
__autoload helper class

Initial Tags

                                

Initial Language
PHP