不知道这个题目行不行。呵呵……我在windows下通过系统自带的计划任务实现到某个时间执行php代码的功能。我简单的试了下,可以通过批处理(D:\server\php5.3.3\php.exe -f E:\workspace\phpStudy\xx.php)实现简单的php代码。但我现在代码比较复杂,而且要用到几个php文件,比如,a.php,b.php,c.php,在a.php要引入b.php和c.php。我那个批处理的文件怎么实现呢?(注:把三个文件放在同一个文件的可能性不大!)请高手帮帮忙。
那这样,写3个批处理文件,在写一个总的BAT文件依次调这三个
require_once 'global.php';
ini_set ( 'memory_limit', '-1' );
set_time_limit ( 0 );
?>
<script>
var http_request = false;
function send_request(url) {//初始化、指定处理函数、发送请求的函数
http_request = false;
//开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest) { //Mozilla 浏览器
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {//设置MiME类别
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) { // IE浏览器
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) { // 异常,创建对象实例失败
window.alert("不能创建XMLHttpRequest对象实例.");
return false;
}
http_request.onreadystatechange = processRequest;
http_request.open("GET", url, true);
http_request.send(null);
}
// 处理返回信息的函数
function processRequest() {
if (http_request.readyState == 4) { // 判断对象状态
if (http_request.status == 200) { // 信息已经成功返回,开始处理信息
// alert(http_request.responseText);
// document.getElementById('show').innerHTML = http_request.responseText;
//document.send.content.value=http_request.responseText;
} else { //页面不正常
alert("您所请求的页面有异常。");
}
}
}
send_request("_AutoMission1_read.php?id=<?=rand ( 1, 10000 )?>");
</script><?php
$countfile = date ( "Y-m-d-H-i-s" ) . ".html";
$str = preg_replace ( "~/[^/]+?$~i", "/_AutoMission1.php", $_SERVER ['HTTP_REFERER'] );
if (! file_exists ( "html/" . $countfile )) {
$fp = fopen ( "html/" . $countfile, "w" );
$ch = curl_init ( $str );
curl_setopt ( $ch, CURLOPT_FILE, $fp );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
$buffer = curl_exec ( $ch );
curl_close ( $ch );
fwrite ( $fp, $buffer );
fclose ( $fp );
}
//显示
include "html/" . $countfile;
?>
我那个标记红色的文件名字:_AutoMission1_read.php和_AutoMission1.php还请帮忙。谢谢!
$str = preg_replace ( "~/[^/]+?$~i", "/_AutoMission1.php", $_SERVER['HTTP_REFERER'] );也不知道什么原因,现在可以运行了。这个批处理没有接触过!nnd!谢谢各位!