E:\php6\ESSamp\ESSamp\wwwroot为网站根目录。
把smarty下载放到E:\
php6\ESSamp\ESSamp\下,不要放在根目录下,防止被别人访问到的可能性,提高安全性。
在php.ini里面的:
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
; Windows: "\path1;\path2"
;include_path = ".:/php/includes"
在windows下把windows一处改为:
include_path = ".;E:\php6\ESSamp\ESSamp\smarty\libs"
重启 apache。
在根目录下新建:
smarty2/templates
smarty2/configs
smarty2/cache
smarty2/templates_c
文件夹。
------------------------------testsmarty1.php-----------------------------------------------------------
<?php
include "Smarty.class.php";
$smarty=new Smarty();
$smarty->template_dir="smarty2/templates";
$smarty->config_dir="smarty2/configs";
$smarty->cache_dir="smarty2/cache";
$smarty->compile_dir="smarty2/templates_c";
//$smarty->left_delimiter='<%';
//$smarty->right_delimiter='%>';
$smarty->assign("name","请问是who?");
$smarty->display('test1.html');
?>
-------------------------------test1.html------------放在smarty2/templates目录里面-----------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>你好,{$name}
</body>
</html>
---------------------------测试效果-----------------------------------------------------