亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php導(dǎo)入模塊文件分享

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

代碼很簡(jiǎn)單,大家注意看注釋就可以了。

復(fù)制代碼 代碼如下:

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

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

相關(guān)文章

最新評(píng)論