方法其实挺多的。以前比较常用的是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:
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