class mysql {
var $linkid=null;
function __construct($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = 'gbk', $connect = 1) {
$this -> connect($dbhost, $dbuser, $dbpw, $dbname, $dbcharset, $connect);
}
class mysql {
var $linkid=null;
function __construct($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = 'gbk', $connect = 1) {
$this -> connect($dbhost, $dbuser, $dbpw, $dbname, $dbcharset, $connect);
}
$times = time();
$filename = $times.".csv";
$a = "联系人,联系电话,申请时间 ";
$days = postget("days");
$mktime = daystomktime($days);
$sql = "select * from v_tugou where ($times-times)<$mktime";
$db = new db();
$result = $db->query( $sql );
$rs = $db->fetch($result,0);
foreach($rs as $v=>$vv)
{
$a.=$vv['name'].','. $vv['mo'].",";
$a.=date('y-m-d ',$vv['times'])." ";
}
//echo $a;
$hod = fopen ($filename,"w+");
if( fwrite($hod,$a) )
{
echo "生成excel文件成功,点击<a href=$filename target=_blank>右击另存为excel文档</a>";
}
<?php教程/* 1.jpg为你想获得其尺寸的图片 */
$arr = getimagesize("1.jpg");
/**
* 这里$arr为一个数组类型
* $arr[0] 为图像的宽度
* $arr[1] 为图像的高度
* $arr[2] 为图像的格式,包括jpg、gif和png等
* $arr[3] 为图像的宽度和高度,内容为 width="xxx" height="yyy"
*/
/* 以下两行代码输出的内容都是一样的 */
echo "<img src="1.jpg" $arr[3] alt="" />";
echo "<img src="1.jpg" width="$arr[0]" height="$arr[1]" alt="" />";
?>
//调用 方法
?>
session_start();
/* get post */
if (!function_exists("getpost")){function getpost(){if(count($_post)){foreach($_post as $key => $value){global ${$key};${$key}=$value;}}}}
class multipage {
var $total;
var $perpage;
var $pages;
var $maxpage;
var $offset = 9;
var $curr_page;
function init($total, $perpage, $maxpage) { //初始化页数
$this->total;
$this->perpage;
$this->maxpage;
$this->offset = 9;
}
function getpagelist() {//获取分页列表
$result_pages = "";
$this->pages = ceil($this->total / $this->perpage);
if ($this->pages > $this->maxpage) {
$from = $this->curr_page - $this->offset;
if ($from < 1) {
$from = 1;
}
$to = $from + $this->maxpage - 1;
if ($to > $this->pages) {
$to = $this->pages;
if (($to - $from) < $this->maxpage) {
$from = $from - 1;
}
}
} else {
$from = 1;
$to = $this->pages;
}
$p = 0;
for($i = $from; $i <= $to; $i++) {
$result_pages[$p] = $i;
$p++;
}
return $result_pages;
}
function getfirst() { //获取第一页
if ($this->curr_page > 1 && $this->pages > 1) {
return 1;
} else {
return "";
}
}
function getlast() { //取末页
if ($this->pages > 1 && $this->curr_page < $this->pages) {
return $this->pages;
} else {
return "";
}
}
function getprev() {//上一页
$prevpage = $this->curr_page - 1;
if ($prevpage > 0) {
return $prevpage;
} else {
$prevpage = "";
return $prevpage;
}
}
function getnext() {//下一页
$nextpage = $this->curr_page + 1;
if ($nextpage <= $this->pages) {
return $nextpage;
} else {
$nextpage = "";
return $nextpage;
}
}
function gettotal() {//共多少页
if ($this->pages > 0) {
return $this->pages;
} else {
return 1;
}
}
}
empty 判断一个变量是否为“空”,isset 判断一个变量是否已经设置。正是这种所谓的“顾名思义”,令我开始时走了些弯路:当一个变量值等于0时,empty()也会成立(true),因而会发生一些意外。原来,empty 和 isset 虽然都是变量处理函数,它们都用来判断变量是否已经配置,它们却是有一定的区别:empty还会检测变量是否为空、为零。当一个变量值为0,empty 认为这个变量同等于空,即相当于没有设置。
比如检测 $id 变量,当 $id=0 时,用empty 和 isset 来检测变量 $id 是否已经配置,两都将返回不同的值—— empty 认为没有配置,isset 能够取得 $id 的值:
php filesystem 函数
rename() 函数重命名文件或目录。
若成功,则该函数返回 true。若失败,则返回 false。
rename(oldname,newname,context)
参数
描述
oldname
必需。规定要重命名的文件或目录。
newname
必需。规定文件或目录的新名称。
context
必需。规定文件句柄的环境。context 是可修改流的行为的一套选项。
注释:在 php 4.3.3 之前,rename() 不能在基于 *nix 的系统中跨磁盘分区重命名文件。
注释:用于 oldname 中的封装协议必须和用于 newname 中的相匹配。
注释:对 context 的支持是 php 5.0.0 添加的。
<?php
rename("images","pictures");
?>
oldpath ----文件或目录原来路径
$newpath ----新定义路径
那么 rename($oldpath,$newpath)就可以完成文件/目录移动的操作
经过我的测试,win32和unix的php4版本都支持这个功能。
另外,好象php4的win32版取消了unlink()函数。那么还可以巧用rename()函数来完成删除的操作,例如:
$path ---- 文件或目录路径
$tmp ---- tmp目录(/tmp)
用rename($path,$tmp) 将文件移动到tmp目录.
得到目前的日期和时间-我们有多少种方式?
2、 改变日期显示的方式-日期和时间的显示形式
3、 转换现在的日期为unix的时间戳值
4、 改变日期
a. 增加时间
b. 减去时间
c. 找出两日期之间的间隔
5、 为php教程添加dateadd函数
6、 为php添加datediff函数
方法一date函数
//2010-08-29 11:25:26
方法二
function delsame(&$array)
{
$i = 0;
while(isset($array[$i]))
{
$j = $i + 1;
while(isset($array[$j]))
{
if($array[$i] == $array[$j]) //如果发现后面有重复的元素
{
delmember($array, $j); //把它删除
$j--; //重新检查补上来的元素是否是重复的
}
$j ++;
}
$i ++;
}
}