* 写入函数
* writer(文件名,写入数据, 写入数据方式);
*/
* 写入函数
* writer(文件名,写入数据, 写入数据方式);
*/
?>
<!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=utf-8" />
<link type="text/css教程" rel="stylesheet" href="common/control.css">
<script type="text/网页特效" language="javascript" src="common/admin.otable.js"></script>
<script type="text/javascript" language="javascript" src="common/include.func.js"></script>
<title>数据管理</title>
<style type="text/css">
span {padding-left:8px;}
</style>
</head>
php代码
<?php session_start();
if($submit=="提交"){
$copy=$_post[copys];
$copys2=$_post[copy2];
if(copy($copy,$copys2)==true){echo "复制成功!!";}else{echo "失败!!";};
}
if($submit2=="提交"){
$moves=$_post[moves];
$moves2=$_post[moves2];
if(rename($moves,$moves2)==true){echo "移动成功!!";}else{echo "失败!!";};
}
html代码
方法一
方法二
$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>";
}
无限file_get_contents获取远程网页内容函数
/*
由于某种原因把php教程的allow_url_fopen选项是关闭了,就是没法直接使用file_get_contents来获取远程web页面的内容。那就是可以使用另外一个函数curl。
// 连接数据库
$conn = mysql_connect("localhost", "phpdb", "phpdb");
mysql_select_db("test",$conn);
?>
<?
// 取得网页的参数
$id=$_post['id'];
<html>
<head>
<title>php教程写的网页计数器代码</title>
<head>
<body>
<?php
$countfile = "counter.txt";
//定义计数器写入的文件是当前目录下的counter.txt文件中,然后我们应当测试该文件能否打开
if (($fp = fopen($countfile, "r+")) == false) {
//用读写模式打开文件,若不能打开就退出
printf ("open file %s failed!",$countfile);
exit;
}
else
{
//如果文件能够正常打开,就读入文件中的数据,假设是1
$count = fread ($fp,10);
//读取10位数据
$count = $count + 1;
//count ++
fclose ($fp);
//关闭当前文件
$fp = fopen($countfile, "w+");
//以覆盖模式打开文件
fwrite ($fp,$count);
//写入加1后的新数据
fputs($fp,$fg);
//显示计数结果
// 数字显示
echo "<div align=center><font size=5>计数次数:$count</font><br>";
require_once './includes/reader.php';
// excelfile($filename, $encoding);
$data = new spreadsheet_excel_reader();
// set output encoding.
$data->setoutputencoding('gbk');
//"data.xls"是指要导入到mysql中(的)excel文件
$data->read('date.xls');
@ $db = mysql_connect('localhost', 'root', '1234') or
die("could not connect to database.");//连接数据库
mysql_query("set names 'gbk'");//输出中文
mysql_select_db('wenhuaedu'); //选择数据库
error_reporting(e_all ^ e_notice);
for ($i = 1; $i <= $data->sheets[0]['numrows']; $i++) {
//以下注释(的)for循环打印excel表数据
for ($j = 1; $j <= $data->sheets[0]['numcols']; $j++) {
echo $data->sheets[0]['cells'][$i][$j].",";
}
echo "n";
$filename = 'cachefile.php';
$str ='echo "bb";';
if( is_file( $filename ) )
{
$tmp = readcache( $filename ) ;
}
else
{
createcache( $filename,$str );
}