Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 915 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

include 'functions.php';

function odt_autoload($classname) {
        
        #修正 $classname
        #涵式說明:
        #將固定格式的字串分開,並回傳分開的結果。
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$result["error"],錯誤訊息陣列
        #$result["function"],當前執行的函數名稱.
        #$result["oriStr"],要分割的原始字串內容
        #$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
        #$result["dataCounts"],爲總共分成幾段
        #必填的參數:
        $conf["stringIn"]=$classname;#要處理的字串。
        $conf["spiltSymbol"]="\\";#爲以哪個符號作爲分割
        $spiltString=\qbpwcf\stringProcess::spiltString($conf);
        unset($conf); 
        
        #如果分割字串失敗
        if($spiltString["status"]=="false"){
                
                #列出錯誤訊息
                var_dump($spiltString);
                
                }#if end
                
        #反之成功但只有分割出大於1段
        else if($spiltString["dataCounts"]>1){
                
                #給予正確的 classname
                $classname=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
                
                }#if end
  
  $classname = strtolower($classname);
  $path = "class.$classname.php";
  if (strpos($classname, 'exception')) {
    $path = "exceptions/class.$classname.php";
  }
  include_once $path;
}

spl_autoload_extensions('.php');
spl_autoload_register('odt_autoload');

?>