Smarty框架根目录缺失问题求助
Smarty框架根目录缺失问题求助
各位大佬好!我最近在本地XAMPP服务器上把Smarty的所有基础配置都搞定了,但现在碰到了根目录访问异常的问题,麻烦帮我分析下相关情况:
情况1
当我访问地址 http://localhost/shopping/login.php 时,页面显示的Smarty安装测试结果如下:
Smarty Installation test... Testing template directory... /Applications/XAMPP/xamppfiles/htdocs/shopping/templates is OK. Testing compile directory... /Applications/XAMPP/xamppfiles/htdocs/shopping/templates_c is OK. Testing plugins
能看到模板目录和编译目录的检测都正常,但到plugins目录的检测就中断了,没有后续的成功提示。我怀疑这和我设置Smarty根目录的方式有关?
我当前初始化Smarty的代码大概是这样的:
require_once 'libs/Smarty.class.php'; $smarty = new Smarty(); $smarty->template_dir = 'templates'; $smarty->compile_dir = 'templates_c'; $smarty->plugins_dir = 'plugins';
是不是因为我用了相对路径,导致根目录解析出现问题?如果换成基于服务器文档根目录的绝对路径会不会解决?比如这样写:
$root_path = $_SERVER['DOCUMENT_ROOT'] . '/shopping/'; $smarty->template_dir = $root_path . 'templates'; $smarty->compile_dir = $root_path . 'templates_c'; $smarty->plugins_dir = $root_path . 'plugins';
另外我也检查了plugins目录的权限,已经设置为755确保可读,应该不是权限的锅。有没有其他可能导致根目录访问异常的原因呀?
内容来源于stack exchange
相关产品推荐
相关产品推荐

