用 ignore_user_abort函数实现php计划任务
说到计划任务大家可能都想到用crontab来实现。可是并不是所有人都是使用linux系统,也不是所有人都有独立服务器。这时候如何用php来
实现计划任务呢。
函数- ignore_user_abort()
,
这个函数可以帮助我们实现像linux中的cron一样实现计划任务,下面一起来看下该如何来实现。
该函数按照字面意思就是“忽略用户中断”,就是使用了该函数的php脚本不管用户有没有退出都会执行下去。
配合set_time_limit 和一个死循环就可以实现计划任务,这样在循环体中,去查询是否有任务需要执行!
例子如下:
ignore_user_abort(); // run script in background
set_time_limit(0); // run script forever
$interval=60*15; // do every 15 minutes...
do{
// add the script that has to be ran every 15 minutes here
// ...
sleep($interval); // wait 15 minutes
}while(true);
但是这个方法也有一个问题,就是当重启了apache之后,脚本就被终止了。
相关文档:
$_FILES['myFile']['name'] 客户端文件的原名称。
$_FILES['myFile']['type'] 文件的 MIME 类型,需要浏览器提供该信息的支持,例如"image/gif"。
$_FILES['myFile']['size'] 已上传文件的大小,单位为字节。
$_FILES['myFile']['tmp_n ......
$file1 = 'F:/46.gif';
$file2 = 'F:/test.txt';
$file3 = 'F:/47.gif';
$size = filesize($file1);
echo '文件大小为:'.$size;
echo "\n<br>转化为二进制 ...";
$content = file_get_contents($file1);
$content = bstr2bin($content);
$fp = fopen($file2, 'w');
fwrite($fp, $content);
fclose($fp);
......
www.diybl.com 时间:2008-06-01 作者:佚名
将其保存成一个文件,用时调用
<?
//为了避免重复包含文件而造成错误,加了判断函数是否存在的条件:
if(!function_exists(pageft)){
//定义函数pageft(),三个参数的含义为:
//$totle:信息总数;
//$displaypg:每页显示信息数,这里设置为默认是20;
//$url:分 ......
搜集不全,链接没有全部测试,大部分可用
Easy Template System
http://ets.sourceforge.net/
http://ets.sourceforge.net/ets.pdf
http://prdownloads.sourceforge.net/ets/ets305b.zip?download
Smarty
http://smarty.php.net/
FastTemplate
http://www.thewebmasters.net/php/FastTemplate.phtml
http://www ......