PHP缓存数组的实现
[ 2011-06-03 08:24:43 | 作者: admin ]
将php文件中经常用到,并且需要经常多次查询数据库的,用到缓存将可以很好的降低内存消耗,加快访问速度。
这里讨论的是使用serialize将数组转成字串,存储在文件中,使用的时候再将字串转换成数组,为什么不用文件直接存储数组,这也是可以的。
PHPWind,discuz就是这么干的,但这里就不讨论了。
通过serialize,unserialize,fread实现存储和释放数组的过程,代码如下:
阅读全文…
这里讨论的是使用serialize将数组转成字串,存储在文件中,使用的时候再将字串转换成数组,为什么不用文件直接存储数组,这也是可以的。
PHPWind,discuz就是这么干的,但这里就不讨论了。
通过serialize,unserialize,fread实现存储和释放数组的过程,代码如下:
function array2file($file,$array){
$fp = fopen($file, "wb");
fwrite($fp, serialize($array));
fclose($fp);
}
function file2array($file){
if(!file_exists($file)){
...$fp = fopen($file, "wb");
fwrite($fp, serialize($array));
fclose($fp);
}
function file2array($file){
if(!file_exists($file)){
阅读全文…
用CSS的padding和border属性为img图片设置双边框效果
[ 2011-06-01 10:43:02 | 作者: admin ]
实现原理:用padding设置图片内边距形成一个边框的效果,用用border设置图片的边框。这样就形式了双边框的效果。可以设置成padding和border相同的宽度,这样出出来的双边框效果比较对称。不过也可以设置边框细一点或内边距小一些,当然你也可以改变背景颜色的方法改变padding形成的边框效果的颜色。希望大家能灵活运用。
阅读全文…
<style type="text/css">
body {text-align: center; font-family:Verdana;}
.img1 { padding:5px; border:5px solid #333;}
.img2 { padding:5px; border:1px solid #333;}
.img3 { padding:5px; border:5px solid #333; background: #c33;}
...body {text-align: center; font-family:Verdana;}
.img1 { padding:5px; border:5px solid #333;}
.img2 { padding:5px; border:1px solid #333;}
.img3 { padding:5px; border:5px solid #333; background: #c33;}
阅读全文…
关于动态指定select的selected的问题,firefox,360,IE不同
[ 2011-05-31 11:27:37 | 作者: admin ]
用ajax制作的一个级联选择,二级随一级联动,在修改的情况下使用下面代码
JS动态改变select选择变更option的index值
[ 2011-05-31 09:41:41 | 作者: admin ]
document.getElementById("louyuming").options[0].selected=true;
function jsSelectIsExitItem(objSelect, objItemValue) {
var isExit = false;
for (var i = 0; i < objSelect.options.length; i++) {
if (objSelect.options[i].value == objItemValue) {
isExit = true;
break;
}
}
...
阅读全文…
function jsSelectIsExitItem(objSelect, objItemValue) {
var isExit = false;
for (var i = 0; i < objSelect.options.length; i++) {
if (objSelect.options[i].value == objItemValue) {
isExit = true;
break;
}
}
...
阅读全文…
AJAX php 二级级联菜单实现代码
[ 2011-05-30 16:26:22 | 作者: admin ]
<!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>
</head>
<script type="text/javascript">
var xmlHttp;
var a =new Array();
function createXMLHttpRequest(){
if(window.ActiveXObject){
...<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
var xmlHttp;
var a =new Array();
function createXMLHttpRequest(){
if(window.ActiveXObject){
阅读全文…
文字遇到图片行高失效解决方案
[ 2011-05-27 16:13:46 | 作者: admin ]
<style type="text/css">
<!--
#title {
font-size: 12px;
line-height: 26px;
}
#title a{zoom:1;} /*(关键) */
-->
</style>
<!--
#title {
font-size: 12px;
line-height: 26px;
}
#title a{zoom:1;} /*(关键) */
-->
</style>
nginx for windows之反向代理
[ 2011-05-27 12:30:24 | 作者: admin ]
1.编辑C:\nginx\conf\nginx.conf
添加修改以下内容:
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 64;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
...
阅读全文…
添加修改以下内容:
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 64;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
...
阅读全文…
一个php水印函数,支持文字和png水印图片
[ 2011-05-25 09:42:50 | 作者: admin ]
ps:使用方法很简单
将水印图片放到执行文件的目录下面,然后赋值各个参数即可,以图片水印为例
阅读全文…
将水印图片放到执行文件的目录下面,然后赋值各个参数即可,以图片水印为例
$imgSrc = “e:/obj.jpg”;
$markImg = "e:/mark.png";
$markText = "";
$TextColor = "";
$markPos = 9; //右下
$fontType = "";
$markType = "img"; //文字水印text或者图片水印img
setWater($imgSrc,$markImg,$markText,$TextColor,$markPos,$fontType,$markType)
$markImg = "e:/mark.png";
$markText = "";
$TextColor = "";
$markPos = 9; //右下
$fontType = "";
$markType = "img"; //文字水印text或者图片水印img
setWater($imgSrc,$markImg,$markText,$TextColor,$markPos,$fontType,$markType)
function setWater($imgSrc,$markImg,$markText,$TextColor,$markPos,$fontType,$markType)
...阅读全文…