怎麼我的Smarty不能用
這個是Smarty.php代碼
define("ROOT", str_replace("\\", "/",dirname(__FILE__)).'/');
require_once ROOT.'libs/Smarty.class.php';
$smarty=new Smarty();
$smarty->setTemplateDir(ROOT."tpl");
$smarty->setCompileDir(ROOT."plusion/templates_c/");
$smarty->setConfigDir(ROOT."plusion/configs/");
$smarty->setCacheDir(ROOT."plusion/cache/");
$smarty->debugging = false;
$smarty->left_delimiter = '<{';
$smarty->right_delimiter = '}>';
?>
這個是Test.php代碼
require "smarty.php";
$smarty->assign("title" , "smarty模板技術");//編輯器提示BUG未定義的變數$smarty,搞不懂上面require進去了,還怎麼報這個錯
$smarty->assign("content","通過詳細的安裝使用步驟為你展示smarty模板技術");
$smarty->display("test.html");
?>
這個是test.html代碼;
<br /><{$title}><br />
<{$content}>
最後在本地localhost竟然原始碼輸出,搞不懂
------解決思路----------------------
怎麼感覺你的Apache和php沒有配置對php指令碼沒有解析呢。
輸出一phpinfo()看看你的Wamp環境對不對。
------解決思路----------------------
test.php
require "smarty.php";
$smarty->assign("title" , "smarty模板技術");//編輯器提示BUG未定義的變數$smarty,搞不懂上面require進去了,還怎麼報這個錯
$smarty->assign("content","通過詳細的安裝使用步驟為你展示smarty模板技術");
$smarty->display("test.html");
?>
------解決思路----------------------
apache httpd.conf 是否設定 .php呢
------解決思路----------------------
#1 和 #3 不知道是怎麼想的!
樓主中分明顯示執行的是 test.php
如果是沒有配置好 php 支援的話,那隻能是產生下載對話方塊
另外,中只顯示有第一個 assign 及以後的內容
顯然是因為沒有開啟短標記功能,程式被原樣輸出了
而
require "smarty.php";
$smarty->
被當做 html 標記,所以不會顯示
查看網頁原始碼時,是都可以看到的