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。