Home  >  Article  >  Backend Development  >  php自动刷新页面

php自动刷新页面

WBOY
WBOYOriginal
2016-06-23 13:32:4312548browse

PHP中怎么样自动刷新当前页面,5秒钟刷新一次,刷新10次停止刷新,给个代码。看了JS刷新,只能设置定时刷新和多少时间刷新一次,不能实现刷新多少次停止。


回复讨论(解决方案)

<?ob_start();if(!isset($_COOKIE['times'])){    $times = 0;    setcookie('times',$times,time()+3600);}else{    $times = $_COOKIE['times']+1;    if($times<=10){        setcookie('times',$times,time()+3600);    }}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>每5秒刷新1次,共刷新10次</title>  <meta http-equiv="content-type" content="text/html; charset=utf-8">  <?php if($times<10){ ?>  <meta http-equiv="refresh" content="5" />  <?php } ?> </head> <body>  <p>每5秒刷新一次,共刷新10次,当前已刷新<?php echo $times ?>次</p> </body></html>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn