作者drlai (苏打)
看板PHP
标题Re: [请益] 使用smarty时,include档案出现问题
时间Thu Aug 17 09:46:04 2006
※ 引述《nsxbaby ()》之铭言:
: 目前我的环境有index.php与main.php以及三个资料夹class、libs、user
: class资料夹中有template.php档案
: libs资料夹中有smarty资料夹(包含了smarty要用的档案与资料夹)
: user资料夹中有个register.php
: index.php会先include('main.php');
: main.php会include资料夹class中的template.php
: 当我用index.php来include('main.php');可以正常运作
: 但是当我要在register.php中include('../main.php');时会出问题
: 错误讯息:
: Warning: main(../WEB/libs/smarty/Smarty.class.php): failed to open stream: No such file or directory in c:\appserv\www\WEB\class\template.php on line 2
: Fatal error: main(): Failed opening required '../WEB/libs/smarty/Smarty.class.php' (include_path='.;c:\php4\pear') in c:\appserv\www\WEB\class\template.php on line 2
: template.php之中用了reauire_once
: require_once ('../WEB/libs/smarty/Smarty.class.php');
: 请问为什麽我在index.php引入main.php的时候,main.php可以require_once('class/Template.php');
: 而在register.php中引入main.php,main.php却会出问题呢?
以下是小弟的一点建议
我撰写网页也是使用Smarty,当然也发生过您说的问题
解决方式是将templete档案分开存放
以後管理上也比较方便,路径问题容易解决
以您的范例来说,我会建立
class (放置index.php所需要的templete)
libs (原本的)
user (原本的)
user/class (放置register.php所需要的templete)
这麽一来路径问题应该可以解决
您试试看吧 :)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 124.10.1.56
1F:推 nsxbaby:解决了 smarty原来是这样运作的 谢谢drlai兄 08/19 22:26