Re: [請益] 使用smarty時,include檔案出現問題
※ 引述《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
推
08/19 22:26, , 1F
08/19 22:26, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章