php自动获取目录下的模板的代码
更新时间:2010年08月08日 17:14:43 作者:
php自定义函数之自动获取目录下的模板的实现代码,一般制作模板分离的管理系统需要用得到。
目录下必须有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 redis Sorted Set实现字符串去重代码示例
Redis中的Sorted Set数据结构可以用来存储有序的唯一值,它们可以被用来构建有序的集合或者有权重的数据结构,下面这篇文章主要给大家介绍了关于PHP redis Sorted Set实现字符串去重的相关资料,需要的朋友可以参考下2023-05-05
PHP中break及continue两个流程控制指令区别分析
php中常用的for与foreach循环中,经常遇到条件判断或中止循环的情况。而处理方式主要用到break及continue两个流程控制指令,现在说明主要区别2011-04-04


最新评论