相同的模板,但是test.php可以加載,運(yùn)行后出結(jié)果,但是使用與test.php同一個(gè)路徑下的commetn.php確提示無法加載模板comment.tpl,請(qǐng)問如何解決?謝謝。文件路徑截圖:smarty.ini.php代碼:<?php
//定義ROOT常量,用來獲取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ì)在頁面源碼中出現(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頁面源碼中出現(xiàn)-->
{$content}
{*?這是smarty注釋,不會(huì)被解析,無法在頁面源代碼中出現(xiàn)?*}
</body>
</html>求大神幫忙解決,謝謝
- 1 回答
- 0 關(guān)注
- 2821 瀏覽
添加回答
舉報(bào)
0/150
提交
取消