php自動獲取目錄下的模板的代碼
更新時間:2010年08月08日 17:14:43 作者:
php自定義函數之自動獲取目錄下的模板的實現代碼,一般制作模板分離的管理系統(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;
}
復制代碼 代碼如下:
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;
}
相關文章
PHP parse_ini_file函數的應用與擴展操作示例
這篇文章主要介紹了PHP parse_ini_file函數的應用與擴展操作,結合實例形式分析了php擴展parse_ini_file函數解析配置文件相關操作技巧,需要的朋友可以參考下2019-01-01修改php.ini實現Mysql導入數據庫文件最大限制的修改方法
這里介紹修改php.ini實現Mysql導入數據庫文件最大限制的修改方法,簡單說明了wampserver服務器上針對php.ini配置文件上傳限制參數、內存限制參數以及post傳輸參數等修改方法,需要的朋友可以參考一下2007-12-12