Heim >Backend-Entwicklung >PHP-Tutorial > 自制一个小小的网站,其中一个功能总是有有关问题,求各位解答
自制一个小小的网站,其中一个功能总是有问题,求各位解答?
one.php:(开始运行的入口)
<br /> <?php<br /> /**<br /> * index.php MyLocalShop 入口<br /> * <br /> * @copyright (C)2013-2014 MyLocalShop<br /> * @license http://www.baidu.com/<br /> * @lastmodify 2013-01-07<br /> */<br /> <br /> <br /> /**<br /> * 网站根目录路径<br /> * @var string<br /> */<br /> define('LOCALSHOP_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);<br /> //echo LOCALSHOP_PATH;<br /> <br /> require_once LOCALSHOP_PATH.'/base.php';<br /> $mls = new MLS();<br /> $mls->Load('front/includes/', 'dindex.phdp'); // 这是错误的,但为什么这里同样正确显示?<br /> $mls->Load('front/includes/', 'index.php'); // 这个才是真正文件名<br /> ?><br />
<br /> <?php<br /> /**<br /> * 显示整个网站的目录树结构<br /> * @author Administrator<br /> *<br /> */<br /> function dir_list() {<br /> return array(<br /> 'admin' => array(<br /> 'css',<br /> 'images',<br /> 'includes' => array(<br /> 'libs'<br /> ),<br /> 'js'<br /> ),<br /> 'common' => array(<br /> 'config' => array(<br /> 'admin' => array(<br /> 'config.php'<br /> ),<br /> 'front' => array(<br /> 'config.php'<br /> ),<br /> 'config.php',<br /> 'dir_list.php'<br /> ),<br /> 'includes' => array(<br /> 'libs'<br /> ),<br /> 'js',<br /> 'languages' => array(<br /> 'en_US' => array(<br /> 'admin' => array(<br /> 'common.php'<br /> ),<br /> 'front' => array(<br /> 'common.php'<br /> )<br /> ),<br /> 'zh_CN' => array(<br /> 'admin' => array(<br /> 'common.php'<br /> ),<br /> 'front' => array(<br /> 'common.php'<br /> )<br /> )<br /> ),<br /> 'templates' => array(<br /> 'Templates.php'<br /> )<br /> ),<br /> 'front' => array(<br /> 'css',<br /> 'images',<br /> 'includes' => array(<br /> 'libs'<br /> ),<br /> 'js'<br /> ),<br /> //'base.php',<br /> //'index.php'<br /> );<br /> }<br /> ?><br />
<br> <?php <br /> /**<br> * MyLocalShop 框架入口<br> * @author Administrator<br> *<br> */<br> require_once LOCALSHOP_PATH.'/common/config/dir_list.php';<br> <br> class MLS {<br> /**<br> * 私有函数。判断是否存在该目录或文件,有则返回true,无则返回false<br> * @param string $target 目录或文件<br> * @return 若判断为文件类型则返回"beFile",若判断为目录类型则返回"beDir";若既不是文件也不是目录则返回 false。<br> */<br> private function hasDirectoryOrFile($target) {<br> $dirs = MLS::load_all_directory();<br> <br> foreach ($dirs as $key => $value) {<br> if (in_array($target, $value)) {<br> $suffix = substr($target, -1, 4);<br> if ($suffix === '.php')<br> /*if (strrchr('.php', $target) || strrchr('.html', $target) || strrchr('.htm', $target) || strrchr('.xhtm', $target) ||<br> strrchr('.xhtml', $target) || strrchr('.tpl', $target) || strrchr('.xml', $target) || strrchr('.xls', $target) || <div class="clear"> </div>