Smarty的保留变量

一 代码

index.php
<?php
	include '../config.php';
	$smarty->assign('title','Smarty保留变量');
	$smarty->display('3/index.tpl');
?>
 
index.tpl
<!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=gb2312" />
<title>{ $title }</title>
<link rel="stylesheet" href="../css/style.css" />
</head>
<body>
{* 使用get变量获取url中的变量值(ex: http://localhost/tm/sl/28/3/index.php?type=computer)*}
变量type的值是:{ $smarty.get.type }<br />
当前路径为:{ $smarty.server.PHP_SELF}<br />
当前时间为:{$smarty.now}
</body>
</html>
 
二 运行结果
变量type的值是:
当前路径为:/test/29/3/index.php
当前时间为:1492600251

猜你喜欢

转载自cakin24.iteye.com/blog/2380004