php smarty 安装 、配置、使用 及缓存cache的配置使用
cache 使用:
cache配置:
$smarty->cache_dir = "/caches/"; //缓存目录
$smarty->caching = true; //开启缓存,为flase的时侯缓存无效
$smarty->cache_lifetime = 60; //缓存时间
cache清除和使用:
$smarty->display('cache.tpl', cache_id); //创建带ID的缓存
cache.tpl //模板文件
$smarty->clear_all_cache(); //清除所有缓存
$smarty->clear_cache('index.htm'); //清除index.tpl的缓存
$smarty->clear_cache('index.htm',cache_id); //清除指定id的缓存
smarty 安装配置 说明:
下载smarty解压 将libs目录 copy到项目主目录下,至少建立如下如下文件夹:templates templates_c configs cache
index.php
<?php
include("libs/Smarty.class.php");
$smarty = new Smarty;
$smarty->template_dir = './templates/';
$smarty->compile_dir = './templates_c/';
$smarty->config_dir = './configs/';
$smarty->cache_dir = './cache/';
$smarty->caching = true;
$smarty->cache_lifetime = 60;
$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
$smarty->assign("title", "垃圾");
$smarty->assign("content","测试用的网页内容00");
$smarty->display("index.tpl",cache_id);
?>
index.tpl模板文件
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><{$title}></title>
</head>
<body>
<{$content}>
</body>
</html>
相关文档:
其实这个的主要部分并不是一个jquery,但是必须使用到
php程序部分,也只需要这个一个php程序就可以了
www.corange.cn亲测
<?php
header("Content-Type: text/html; charset=utf-8");
@header( "Cache-Control: no-cache, must-revalidate" );
@header( "Pragma: no-cache" );
@header( "Last-Modified: " ......
PHP函数setcookie()用来设置cookie.
setcookie()函数必须在<html>标签之前调用,语法是setcookie (name, value, expire,
path, domain) 例如:
<?php
setcookie(”user”, “Alex
Porter”, time()+3600);
?>
<?php
setcookie(”url”, “http://www.mianwww. ......
2008 年 12 月 29 日
像其他语言一样,开发人员可以用 PHP 编写出各种质量级别的代码。学习良好的编程习惯能够提高代码质量和效率。
根据具体的情况,一般的开发人员往往比优秀的开发人员的效率低 10%~20%。优秀的开发人员的效率更高,因为他们拥有丰富的经验和良好的编程习惯。不良的编程习惯将会影响到效率。本文通过展 ......
【1】页面之间无法传递变量 get,post,session在最新的php版本中自动全局变量是关闭的,所以要从上一页面取得提
交过来得变量要使用$_GET['foo'],$_POST['foo'],$_SESSION['foo']来得到。当然也可以修改自动全局变量为开
(php.ini改为register_globals = On);考虑到兼容性,还是强迫自己熟悉新的写法比较好。
【2 ......
一、问题起源
稍大一些的网站,通常都会有好几个服务器,每个服务器运行着不同功能的模块,使用不同的二级域名,而一个整体性强的网站,用户系统是统一的,即一套
用户名、密码在整个网站的各个模块中都是可以登录使用的。各个服务器共享用户数据是比较容易实现的,只需要在后端放个数据库服务器,各个服务器通过统一接
......