php自動獲取目錄下的模板的代碼
更新時間:2010年08月08日 17:14:43 作者:
php自定義函數(shù)之自動獲取目錄下的模板的實(shí)現(xiàn)代碼,一般制作模板分離的管理系統(tǒng)需要用得到。
目錄下必須有default.gif(此圖為模板縮略圖)的才為合法的模板
function get_template ()
{
$template = array ();
$dir = CMS_ROOT.'/tpl/';
$n = 0;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file =='.' or $file == '..' or $file == '.svn')
{
continue;
}
if (is_dir ($dir.$file))
{
if (file_exists ($dir.$file.'/default.gif'))
{
$template[$n]['dir'] = $file;
$template[$n]['pic'] ='/tpl/'.$file.'/default.gif';
}
}
$n++;
}
closedir($dh);
}
}
return $template;
}
復(fù)制代碼 代碼如下:
function get_template ()
{
$template = array ();
$dir = CMS_ROOT.'/tpl/';
$n = 0;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file =='.' or $file == '..' or $file == '.svn')
{
continue;
}
if (is_dir ($dir.$file))
{
if (file_exists ($dir.$file.'/default.gif'))
{
$template[$n]['dir'] = $file;
$template[$n]['pic'] ='/tpl/'.$file.'/default.gif';
}
}
$n++;
}
closedir($dh);
}
}
return $template;
}
您可能感興趣的文章:
- 讓你的博文自動帶上縮址的實(shí)現(xiàn)代碼,方便發(fā)到微博客上
- 用ajax自動加載blogjava和博客園的rss
- Linux下SVN服務(wù)器自動更新文件到Web目錄的方法
- rsync備份時自動創(chuàng)建目錄的方法
- 使用visual studio自動創(chuàng)建IIS虛擬目錄
- Windows下實(shí)現(xiàn)MySQL自動備份的批處理(復(fù)制目錄或mysqldump備份)
- 使用FTP下載目錄,即FTP命令批量自動下載的bat文件
- 使用ADSI、ASP和一對魔術(shù)戲法自動地創(chuàng)立一個虛擬目錄的方法
- 一個可以自動創(chuàng)建多級目錄的函數(shù)
- 詳解自動生成博客目錄案例
相關(guān)文章
PHP實(shí)現(xiàn)會員賬號單唯一登錄的方法分析
這篇文章主要介紹了PHP實(shí)現(xiàn)會員賬號單唯一登錄的方法,結(jié)合實(shí)例形式分析了php基于session與文件讀寫的單一用戶登陸限制實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-03-03
PHP parse_ini_file函數(shù)的應(yīng)用與擴(kuò)展操作示例
這篇文章主要介紹了PHP parse_ini_file函數(shù)的應(yīng)用與擴(kuò)展操作,結(jié)合實(shí)例形式分析了php擴(kuò)展parse_ini_file函數(shù)解析配置文件相關(guān)操作技巧,需要的朋友可以參考下2019-01-01
PHP簡單實(shí)現(xiàn)二維數(shù)組賦值與遍歷功能示例
這篇文章主要介紹了PHP簡單實(shí)現(xiàn)二維數(shù)組賦值與遍歷功能,涉及php數(shù)組的簡單賦值、遍歷、運(yùn)算、讀取等操作使用技巧,需要的朋友可以參考下2017-10-10
批量獲取memcache值并按key的順序返回的實(shí)現(xiàn)代碼
一臺memcache時返回是正確的,在有多臺memcache時就無法一一對應(yīng)的按順序返回。2011-06-06
修改php.ini實(shí)現(xiàn)Mysql導(dǎo)入數(shù)據(jù)庫文件最大限制的修改方法
這里介紹修改php.ini實(shí)現(xiàn)Mysql導(dǎo)入數(shù)據(jù)庫文件最大限制的修改方法,簡單說明了wampserver服務(wù)器上針對php.ini配置文件上傳限制參數(shù)、內(nèi)存限制參數(shù)以及post傳輸參數(shù)等修改方法,需要的朋友可以參考一下2007-12-12

