Recently did not do, research and research smarty template engine, more and more feel smarty strong, smarty tutorials on the internet seems to be quite messy.
1. Download Smarty,http://www.smarty.net/download
2. Rename the downloaded Smarty to Smarty and copy to the new folder
3. Create a new smarty.inc.php (or it can be something else)
<?php require_once ' smarty/smarty.class.php ';
$smarty =new smarty ();
$smarty->template_dir= ' templates/';
$smarty->compile_dir= ' templates_c/';
$smarty->cache_dir= ' temp/';
$smarty->config_dir= ' configs/'; $smarty->caching=0;
Cache $smarty->cache_lifetime=60; if (!defined (' Site_url ')) {$url =$_server[' request_scheme ']. ':/
/'. $_server[' Http_host '];
Define (' Site_url ', $url); } if (!defined (' __root__ ')) {define (' __root__ ', RTrim (DirName (__file__), ' \ \ '). '
\\'); ///Remove backslash if (GET_MAGIC_QUOTES_GPC ()) {function Stripcslashes_arr ($array) {Is_array ($array)? Array_map (' Srtipcs
Lashes_arr ', $array): Stripcslashes ($array);
} $_post=stripcslashes_arr ($_post);
$_get=stripcslashes_arr ($_get);
$_request=stripcslashes_arr ($_request);
$_cookie=stripcslashes_arr ($_cookie);
$_session=stripcslashes_arr ($_session);
}//Time zone set Date_default_timezone_set (' PRC '); Load function if (file_exists (' common/common.php ')) {require_once ' common/common.php ';}
and manually set up the appropriate directory, debugging, it is recommended to turn off the cache.
And then a new index.php,
<?php
require_once ' smarty.inc.php ';
$title = ' first title ';
$smarty->assign (' title ', $title);
$people =array (
Array (' name ' => ' John ', ' Sex ' => ' man ', ' age ' => '),
Array (' name ' => ' Dick ', ' sex ') Male ', ' age ' => '),
Array (' name ' => ' Harry ', ' Sex ' => ' woman ', ' age ' => '),
);
$smarty->assign (' People ', $people);
$smarty->display (' Index.tpl ');