相同的模板,但是test.php可以加載,運(yùn)行后出結(jié)果,但是使用與test.php同一個(gè)路徑下的commetn.php確提示無(wú)法加載模板comment.tpl,請(qǐng)問(wèn)如何解決?謝謝。文件路徑截圖:smarty.ini.php代碼:<?php
//定義ROOT常量,用來(lái)獲取smarty模板引擎的存放絕對(duì)路徑
define('ROOT',str_replace('\\','/',realpath(__DIR__.'/../')));
include?ROOT.'/libs/Smarty.class.php';
$smarty?=?new?Smarty;
?>test.php代碼:<?php
include?'smarty.ini.php';
$smarty?->?assign('title','1');
$smarty?->?assign('content','2');
$smarty?->?display('comment.tpl');
?>commetn.php代碼:<?php
include?'smarty.ini.php';
$smarty?->?assign('title','HTML注釋與Smarty模板引擎注釋的區(qū)別');
$smarty?->?assign('content','<b>HTML注釋會(huì)在頁(yè)面源碼中出現(xiàn),而smarty注釋則不會(huì),
smarty注釋的方法是在將注釋內(nèi)容用*號(hào)包圍,而星號(hào)又被左右定界符包圍。</b>');
$smarty?->?display('commetn.tpl');
?>commetn.tppl代碼:<html>
<head>
<title>{$title}</title>
</head>
<body>
<!--這里是HTML注釋,會(huì)在html頁(yè)面源碼中出現(xiàn)-->
{$content}
{*?這是smarty注釋,不會(huì)被解析,無(wú)法在頁(yè)面源代碼中出現(xiàn)?*}
</body>
</html>求大神幫忙解決,謝謝
1 回答

KevenHuang
TA貢獻(xiàn)280條經(jīng)驗(yàn) 獲得超233個(gè)贊
如果覺(jué)得沒(méi)有加載成功,可以首先打印一下路徑是不是正確的,再一步步的去排錯(cuò)。
- 1 回答
- 0 關(guān)注
- 2864 瀏覽
添加回答
舉報(bào)
0/150
提交
取消