發(fā)表日期:2018-03 文章編輯:小燈 瀏覽次數(shù):3322
今天在對dede的問答模塊進行修改的時候發(fā)現(xiàn)直接調(diào)用/include/helpers/archive.helper.php文件中的函數(shù)居然是可行的,但是找遍了ask模塊的所有代碼都沒有發(fā)現(xiàn)這個是文件如何引入的。我記得有人說過dede的helper文件由系統(tǒng)自動引入,不需要自己手動完成。但是這個東西是如何自動引入的呢,是所有的地方都能用/include/helpers/目錄下面的所有文件嗎?
答案是否。
官方之所以說/include/helpers/下面的文件自動引入 是因為dede的php文件中幾乎都require了/include/common.inc.php這個初始化文件,而這個文件中完成了對所有/include/helpers/下面的文件自動引入。相關(guān)代碼如下:
if(file_exists(DEDEDATA.'/helper.inc.php')){require_once(DEDEDATA.'/helper.inc.php');// 若沒有載入配置,則初始化一個默認小助手配置if (!isset($cfg_helper_autoload)){$cfg_helper_autoload = array('util', 'charset', 'string', 'time', 'cookie');}// 初始化小助手helper($cfg_helper_autoload);} |
這段代碼的意思是如果變量$cfg_helper_autoload已經(jīng)存在,則執(zhí)行helper($cfg_helper_autoload);而默認是存在的。helper()這個函數(shù)實現(xiàn)了具體引入哪些/include/helpers/下面的文件,是哪些呢,這要取決于$cfg_helper_autoload變量的內(nèi)容。
我們看看這個$cfg_helper_autoload里面有些什么東西。原來這個變量是在/data//helper.inc.php中定義的:
<?php//小助手配置項$cfg_helper_autoload = array('charset', /* 編碼小助手 */'channelunit',/* 模型單元小助手 */'string', /* 字符串小助手 */'time', /* 日期小助手 */'file', /* 文件小助手 */'util', /* 單元小助手 */'validate', /* 數(shù)據(jù)驗證小助手 */'filter', /* 過濾器小助手 */'cookie', /* cookies小助手 */'debug', /* 調(diào)試小助手 */'archive', /* 文檔小助手 */'upload', /* 上傳小助手 */'extend', /* 擴展小助手 */);?> |
看到了吧 默認引用的helper中已經(jīng)包括了archive文檔小助手,而ask模塊一開始就是require了/include/common.inc.php的,因此一層一層的分析下來,可以得出這樣的結(jié)論,凡是引入和/include/common.inc.php文件的php代碼,都是能直接執(zhí)行默認的那幾個助手小工具里面的代碼的。
日期:2018-10 瀏覽次數(shù):3750
日期:2018-10 瀏覽次數(shù):3498
日期:2018-08 瀏覽次數(shù):3582
日期:2018-06 瀏覽次數(shù):3334
日期:2018-06 瀏覽次數(shù):3182
日期:2018-06 瀏覽次數(shù):3234
日期:2018-06 瀏覽次數(shù):3495
日期:2018-06 瀏覽次數(shù):3337
日期:2018-06 瀏覽次數(shù):3257
日期:2018-06 瀏覽次數(shù):3432
日期:2018-05 瀏覽次數(shù):3340
日期:2018-05 瀏覽次數(shù):4149
日期:2018-05 瀏覽次數(shù):3253
日期:2018-05 瀏覽次數(shù):3666
日期:2018-04 瀏覽次數(shù):4118
日期:2018-03 瀏覽次數(shù):3258
日期:2018-03 瀏覽次數(shù):3134
日期:2018-03 瀏覽次數(shù):3321
日期:2018-02 瀏覽次數(shù):3314
日期:2018-02 瀏覽次數(shù):3282
日期:2017-12 瀏覽次數(shù):3424
日期:2017-12 瀏覽次數(shù):3656
日期:2017-12 瀏覽次數(shù):3842
日期:2017-12 瀏覽次數(shù):3216
日期:2017-12 瀏覽次數(shù):3202
日期:2017-11 瀏覽次數(shù):3240
日期:2017-11 瀏覽次數(shù):3312
日期:2017-11 瀏覽次數(shù):3210
日期:2017-11 瀏覽次數(shù):3338
日期:2017-11 瀏覽次數(shù):3906
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.