- 論壇徽章:
- 0
|
本帖最后由 yum2014 于 2014-05-07 15:48 編輯
win7 64位+wamp.
php版本是5.3.
smarty2.6解壓后。libs目錄改名為smarty文件夾。復(fù)制到www下的news目錄下。
建立了一個(gè)smarty.php文件內(nèi)容是- <?
- //引用文件
- include "./Smarty/Smarty.class.php";
- $smarty=new Smarty;
- //var_dump($smarty);
- $smarty->template_dir="./templates";//設(shè)置模板目錄
- $smarty->compile_dir="./templates_c";//設(shè)置編譯目錄。必選的。
- $smarty->config_dir="Smarty/Config_File.class.php";//目錄變量
- $smarty->caching=false;//是否使用緩存,項(xiàng)目調(diào)試期間,不建議啟用緩存
- $smarty->cache_dir="./smarty_cache";//緩存文件夾.可選的。
- $smarty->left_delimiter="<{";
- $smarty->right_delimiter="}>";
- ?>
復(fù)制代碼 建立一個(gè)模板文件xx.htm- <html>
- <head>
- <title>測試</title>
- </head>
- <body>
- <body>
- 歡迎<{$name}>光臨smarty網(wǎng)站;
- 年齡:<{$age}>
- </body>
- </body>
- </html>
復(fù)制代碼 建立一個(gè)php文件(i2.php)- <?php
- include('./smarty.php');
- $name="dengwei";
- $age=27;
- $smarty->assign('name',$name);
- $smarty->assign('age',$age);
- #$smarty->display("./templates/xx.htm");
- $smarty->display("./xx.htm");
- ?>
復(fù)制代碼 而后訪問 http://localhost/news/i2.php
結(jié)果報(bào)錯(cuò)了。。。根本沒有顯示預(yù)期的。。。求問是哪里出錯(cuò)了? |
|