phpsettimeout
⑴ php 延迟异步执行执行怎么做
用js,给b方法加个setTimeout()定时器,设定20秒后执行b方法即可,其他方法正常运行。
setTimeout() :在指定的毫秒数后调用函数或计算表达式。
⑵ PHP网页定时刷新的代码程序是什么
定时刷新网页是js的功能吧
<script language="javaScript">
function re_fresh() {
window.location.reload();
}
setTimeout('re_fresh()',2000); //指定2秒刷新一次
</script>
不过这样做对服务器会造成很大压力,不是必要的,不要这么做
⑶ php如何实现页面跳转功能,跳转一下,然后返回
<meta http-equiv="refresh" content="5;url=http://www..com">
这不就行了 HTML代码
你说的跳转返回 如果是无限次的就用这个HTML吧
如果是指跳一次的 就用session写个判断 跳过就不跳了·
⑷ 急!!php如何设置10秒后自动运行后面的代码
用js 会更简单一些
<script>
//定时器 异步运行
function hello(){
alert("hello");
}
//使用方法名字执行方法
var t1 = window.setTimeout(hello,1000);
var t2 = window.setTimeout("hello()",3000);//使用字符串执行方法
window.clearTimeout(t1);//去掉定时器
</script>
你可以试试这段代码
⑸ php循环倒计时的代码
这个可能要配合子框架和JS的功能来实现.
思路是:
1. 在主框架页面上,安排一个表单 + 一个文本框(设变量名为 end_time),用来设置时间(target 指向子框)(日期格式: 2009-05-28 12:00:00 )
2. 再插入一个对象用来显示剩余时间(可以是文本框,也可以是<span>标记,还可以是其它可以用JS替换内容的对象就可以了)(假设它的标记是<span id="timeout"></span>).
3. 在主框架上插入一子框架,子框架的源文件指向php文件
4. 在PHP源文件中插入适当代码.代码的作用主要分几部分,
A.计算剩余时间
B.用于更新主页面的剩余时间对象的JS代码.
C.适当设置页面刷新的时间(用JS或刷页刷新代码)
部分代码:
1.主框架(index.php)
<form action="timer.php" method="post" name="form1" target="timerframe" id="form1">
<table border="0">
<tr>
<td>开始时间
<label></label></td>
<td><input name="end_time" type="text" id="end_time" value="<?php echo date("Y-m-d H:i:s");?>" /></td>
<td><label>
<input type="submit" name="Submit" value="提交" />
</label></td>
</tr>
</table>
<table width="400" border="0">
<tr>
<td> </td>
</tr>
<tr>
<td>离结束还有:<span class="STYLE1" id="timeout">aaaaa</span></td>
</tr>
</table>
</form>
<iframe name="timerframe" width="1" height="1"></iframe>
2.子框架(timer.php)
<body>
<?php
$endTime=strtotime($_REQUEST['end_time']); //将终止时间转为nix_timestamp格式
$now=time(); //当前时间
//printf( "N:%s,\n<br>E:%s\n<br>",$now,$endTime);
if($now>=$endTime) //如果时间已过结束时间
{
?>
<script language="javascript">
var f=parent.document.getElementById("form1")
f.end_time.value='<?php echo date("Y-m-d H:i:s",$endTime+2*3600);?>'
f.submit()
</script>
<?php
exit;
}
$timeLeft=$endTime-$now; //计算剩余的秒数,并转换为对应的 时:分:秒 的格式
?>
<script language="javascript">
parent.document.getElementById("timeout").innerHTML='<?php echo date("H:i:s",$timeLeft-8*3600);?>'
function refresh()
{
var f=parent.document.getElementById("form1")
f.submit();
}
setTimeout("refresh()",5000)
</script>
</body>
⑹ php语句,定时自动刷新的语句
页面刷新:
有三种方法:
1,在html中设置:
<title>xxxxx</title>之后加入下面这一行即可!
定时刷新:<META HTTP-EQUIV="Refresh" content="10;url=网页名">
10代表刷新间隔,单位为秒
2.PHP
<meta http-equiv=”Refresh” content=”3;URL=<?php echo ‘index.php?’.rand(0,999);?>” />
这里是定为3秒钟刷新一次~
3.使用javascript:
<script language="javascript">
setTimeout("self.location.reload();",1000);
<script>
一秒一次
页面自动跳转:
1,在html中设置:
<title>xxxxx</title>之后加入下面这一行即可!
定时跳转并刷新:<meta http-equiv="refresh" content="20;url=http://自己的URL">,
其中20指隔20秒后跳转到http://自己的URL 页面。
< META HTTP-EQUIV="REFRESH" CONTENT="x; URL=*.*">
记得要设置 url~
⑺ 如何编写让php页面自动刷新
需要准备的材料分别是:电脑、php编辑器、浏览器。
1、首先,打开php编辑器,新建php文件,例如:index.php。