欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php導入模塊文件分享

 更新時間:2015年03月17日 14:27:11   投稿:hebedich  
本文給大家分享的是php導入模塊文件分享,主要參數(shù)有導入文件路徑字符串,可以用"."代替"/", 導入文件類型的擴展名(帶"."號),也可以是class/inc(簡寫方式), 如果導入成功則返回true,否則返回異常對象,有需要的小伙伴參考下吧。

代碼很簡單,大家注意看注釋就可以了。

復制代碼 代碼如下:

/**
 * 導入模塊文件
 *
 * @param string $classString 導入文件路徑字符串,可以用"."代替"/"
 * @param string $fileType 導入文件類型的擴展名(帶"."號),也可以是class/inc(簡寫方式)
 * @return Exception 如果導入成功則返回true,否則返回異常對象
 *
 * @example
 * importModule('gapi.Account') => include_once('modules/gapi/Account.class.php');
 */
function importModule($classString, $fileType = 'class')
{
    $filename = $module_path. strtr($classString, '.', '/');
    switch ($fileType) {
        //導入類文件
        case 'class': $filename .= '.class.php'; break;
        //導入包含文件
        case 'inc': $filename .= '.inc.php'; break;
        //自定義導入文件的擴展名
        default: $filename .= $fileType; break;
    }
    if (is_file($filename))
    {
        include_once($filename);
    }
    else
    {
        exit('class "\\' . strtr($classString, '.', '\\') . '" is not found.');
    }
}

以上就是本文分享給大家的代碼了,希望大家能夠喜歡。

相關文章

最新評論