php require加载smarty类库出错
错误提示如下:Warning:require(D:/ProgramFiles/ApacheSoftwareFoundation/Apache2.2/htdocsmessa...
错误提示如下:
Warning: require(D:/Program Files/Apache Software Foundation/Apache2.2/htdocsmessage1\27\Smarty\Smarty.class.php) [function.require]: failed to open stream: No such file or directory in D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\27\config.php on line 7
Fatal error: require() [function.require]: Failed opening required 'D:/Program Files/Apache Software Foundation/Apache2.2/htdocsmessage1\27\Smarty\Smarty.class.php' (include_path='.;C:\php\pear') in D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\27\config.php on line 7
conf.php源代码如下:
/* 定义服务器的绝对路径 */
define('BASE_PATH',$_SERVER['DOCUMENT_ROOT']);
/* 定义Smarty目录的绝地你路径 */
define('SMARTY_PATH','message1\27\Smarty\\'); //原来的string是'\tm\sl\27\Smarty\\',我改成我自己的路径了。
/* 加载Smarty类库文件 */
require BASE_PATH.SMARTY_PATH.'Smarty.class.php';
/* 实例化一个Smarty对象 */
$smarty = new Smarty;
/* 定义各个目录的路径 */
$smarty->template_dir = BASE_PATH.SMARTY_PATH.'templates/';
$smarty->compile_dir = BASE_PATH.SMARTY_PATH.'templates_c/';
$smarty->config_dir = BASE_PATH.SMARTY_PATH.'configs/';
$smarty->cache_dir = BASE_PATH.SMARTY_PATH.'cache/';
新手跪求原因。另外错误显示那个$_SERVER['DOCUMENT_ROOT']取得的路径是用“\”隔开的,书上正反斜杠混用了吗?可以吗?正反斜杠到底怎么用呢?
谢谢!!! 展开
Warning: require(D:/Program Files/Apache Software Foundation/Apache2.2/htdocsmessage1\27\Smarty\Smarty.class.php) [function.require]: failed to open stream: No such file or directory in D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\27\config.php on line 7
Fatal error: require() [function.require]: Failed opening required 'D:/Program Files/Apache Software Foundation/Apache2.2/htdocsmessage1\27\Smarty\Smarty.class.php' (include_path='.;C:\php\pear') in D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\27\config.php on line 7
conf.php源代码如下:
/* 定义服务器的绝对路径 */
define('BASE_PATH',$_SERVER['DOCUMENT_ROOT']);
/* 定义Smarty目录的绝地你路径 */
define('SMARTY_PATH','message1\27\Smarty\\'); //原来的string是'\tm\sl\27\Smarty\\',我改成我自己的路径了。
/* 加载Smarty类库文件 */
require BASE_PATH.SMARTY_PATH.'Smarty.class.php';
/* 实例化一个Smarty对象 */
$smarty = new Smarty;
/* 定义各个目录的路径 */
$smarty->template_dir = BASE_PATH.SMARTY_PATH.'templates/';
$smarty->compile_dir = BASE_PATH.SMARTY_PATH.'templates_c/';
$smarty->config_dir = BASE_PATH.SMARTY_PATH.'configs/';
$smarty->cache_dir = BASE_PATH.SMARTY_PATH.'cache/';
新手跪求原因。另外错误显示那个$_SERVER['DOCUMENT_ROOT']取得的路径是用“\”隔开的,书上正反斜杠混用了吗?可以吗?正反斜杠到底怎么用呢?
谢谢!!! 展开
展开全部
路径不对
D:/Program Files/Apache Software Foundation/Apache2.2/htdocsmessage1\27\Smarty\Smarty.class.php
应该是
D:/Program Files/Apache Software Foundation/Apache2.2/htdocs/message1\27\Smarty\Smarty.class.php
原因是
define('SMARTY_PATH','message1\27\Smarty\\');
修改为
define('SMARTY_PATH','\message1\27\Smarty\\');
D:/Program Files/Apache Software Foundation/Apache2.2/htdocsmessage1\27\Smarty\Smarty.class.php
应该是
D:/Program Files/Apache Software Foundation/Apache2.2/htdocs/message1\27\Smarty\Smarty.class.php
原因是
define('SMARTY_PATH','message1\27\Smarty\\');
修改为
define('SMARTY_PATH','\message1\27\Smarty\\');
追问
谢谢,我找到原因了,我多写了个message1,我还想问下书中作者是不是在路径上正斜杠和反斜杠混在一起用了呢?我都改成反斜杠了就能用了,你能说一下正反斜杠的问题吗?
谢谢
追答
好的,windows系统支持/和\两种表示文件路径的方法,而其他操作系统如linux只支持/表示的路径,所以为了兼容一般都用/表示。
你的服务器操作系统应该是windows吧,所以才会出现\和/混合在一起的,如果是在linux系统下你会发现都是/表示的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询