PHP详细彻底学习Smarty

2019-04-10 22:34:50于海丽

是到smarty类目录的完全路径,必须以/结束。如果没有定义,将会自动决定路径. 

SMARTY_CORE_DIR 
是到smarty类core文件目录的完全路径,必须以/结束。如果没有定义,将会自动定义为smarty_dir路径下面的子目录. 


变量 

$template_dir 
默认的模板目录名,默认为"./templates". 
$compile_dir 
默认的编译模板目录名,默认为"./templates_c" 
$config_dir 
默认的config文件目录名,默认为"./configs". 
$plugins_dir 
默认的插件目录名,默认为"plugins". 
$debugging 
debugging控制台。即一个显示变量的窗口. 
$debug_tpl 
debug窗口的模板 
$debugging_ctrl 
另一种控制debugging的方法。 
$autoload_filters 
对所有的模板使用过滤程序,这个变量是一个数组,其中关键字是过滤的类型,值是过滤的名字。 
$compile_check 
每次php执行将是否查看模板的内容是否改变。 

$caching 
决定是否缓存文件执行生成的文件。 
$cache_dir 
默认的模板缓存目录名,默认为"./cache". 
$cache_lifetime 
缓存的模板的过期时间,以秒计算. $caching值为-1则缓存的模板永不过期.
最后我放个我用的例子.大家仅做一个参考吧

<?php
error_reporting(7);
$TurnDot  =  substr(PHP_OS, 0, 3) == 'WIN'  ?  ";"  :  ":"  ;
$doc_root=$_SERVER['DOCUMENT_ROOT'];   //默认获取根路径
//$doc_root="E:/Myweb/an-cool.com/Web" ; //这里是指定路径
$lib_root=".".$TurnDot.$doc_root."/shopadmin".$TurnDot.$doc_root."/shopadmin/inc".$TurnDot.$doc_root."/".$TurnDot.$doc_root."/jpgraph/src/".$TurnDot.$doc_root."/Smarty/libs/".$TurnDot.$doc_root."/Smarty";
ini_set("include_path",$lib_root);
include("conf.global.php");  //这里是装载一个全局配置文件.
$Templates_root = $doc_root."/templates";  //定义摸版根目录
define("Templates",$Templates_root);
$templates  = isset($INFO['templates'])  ?  $INFO['templates']  :  'default'  ;
include_once('Smarty.class.php');
$tpl = new Smarty();                                                                   //建立smarty实例对象$tpl 
$tpl->debugging = false;
$tpl->template_dir   = Templates."/".$templates  ;                             //设置模板目录
相关文章 大家在看