Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5002395
  • 博文数量: 921
  • 博客积分: 16037
  • 博客等级: 上将
  • 技术积分: 8469
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-05 02:08
文章分类

全部博文(921)

文章存档

2020年(1)

2019年(3)

2018年(3)

2017年(6)

2016年(47)

2015年(72)

2014年(25)

2013年(72)

2012年(125)

2011年(182)

2010年(42)

2009年(14)

2008年(85)

2007年(89)

2006年(155)

分类:

2010-07-16 10:13:27

有用的一些函数,你可以作为源码保存,然后以后避免重复编写。


<?php
//文件读取函式

function PHP_Read($file_name) {
$fd=fopen($file_name,r);
while($bufline=fgets($fd, 4096)){
$buf.=$bufline;
}
fclose($fd);
return $buf;
}


//文件写入函式

function PHP_Write($file_name,$data,$method="w") {
$filenum=@fopen($file_name,$method);
flock($filenum,LOCK_EX);
$file_data=fwrite($filenum,$data);
fclose($filenum);
return $file_data;
}



//静态页面生成函式

function phptohtm($filefrom,$fileto,$u2u=1){
if($u2u==1){
$data=PHP_Read($filefrom);
}else{
$data=$filefrom;
}
PHP_Write($fileto,$data);
return true;
}


阅读(1522) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~