Home > Backend Development > PHP Tutorial > 浅析PHP页面局部刷新功能的实现小结_PHP

浅析PHP页面局部刷新功能的实现小结_PHP

WBOY
Release: 2016-06-01 12:05:36
Original
1225 people have browsed it

方法其实挺多的。以前比较常用的是iframe这样来做。现在多了个ajax,所以一般情况下都是用的ajax。
第一种方法,ajax实现:
当然,ajax使用起来确实很简单就可以实现,但是里面的很多知识还是比较有点深的。我之前做页面时间自动刷新的功能就是用的ajax。完整代码是:
1.getTime.php:
复制代码 代码如下:
header("cache-control:no-cache,must-revalidate"); 
header("Content-Type:text/html;charset=utf-8");
$time = "2012-1-20 18:00:00";
$dt_element=explode(" ",$time);
$date_element=explode("-",$dt_element[0]);
$time_element=explode(":",$dt_element[1]);
$date = mktime($time_element[0],$time_element[1],$time_element[2],$date_element[1],$date_element[2],$date_element[0]);
$nowTime = time(); 
$showtime = date("北京时间Y年m月d日H:i:s",$date-$nowTime); 
if($showtime echo "happy new year";
}
echo $showtime;

2.zidong.php:
复制代码 代码如下:
 

 

Ajax动态显示时间

 
 

当前时间:

 
 

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template