php自动获取目录下的模板的代码

yipeiwu_com6年前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;
}

相关文章

php数据结构与算法(PHP描述) 查找与二分法查找

复制代码 代码如下: <?php /** * 查找 * **/ // 顺序查找 function normal_search($arrData,$val) { $len = cou...

php 截取GBK文档某个位置开始的n个字符方法

cut.php: #!/usr/bin/php <?php define('INPUT_FILE', 't.txt'); define('OUTPUT_FILE', '...

php中heredoc与nowdoc介绍

Heredoc技术,在正规的PHP文档中和技术书籍中一般没有详细讲述,只是提到了这是一种Perl风格的字符串输出技术。但是现在的一些论坛程序,和部分文章系统,都巧妙的使用heredoc技...

PHP中file_exists与is_file,is_dir的区别介绍

很显然file_exists是受了asp的影响,因为asp不但有fileExists还有folderExists,driverExists,那么PHP中file_exists是什么意思呢...

php从字符串创建函数的方法

本文实例讲述了php从字符串创建函数的方法。分享给大家供大家参考。具体如下: php中可以把整个函数定义放到一个字符串内动态定义,有了create_function这个函数,你就可以根据...