如何小弟我的Smarty不能用

來源:互聯網
上載者:User
怎麼我的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 標記,所以不會顯示
查看網頁原始碼時,是都可以看到的
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.