This article provides a detailed analysis of the implementation of the PHP page partial refresh function. Many methods are required for reference. Iframe is commonly used in the past. Now there is more ajax, So ajax is usually used.
The first method is ajax implementation:
Of course, ajax can be implemented easily, but there is a lot of knowledge in it. I used ajax to automatically refresh the page time. The complete code is:
1. getTime. php:
The code is as follows:
Header ("cache-control: no-cache, must-revalidate ");
Header ("Content-Type: text/html; charset = utf-8 ");
$ Time = "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 ("Beijing Time, Y, m, d, H: I: s", $ date-$ nowTime );
If ($ showtime <= "January 01, 1970 08:00:00 Beijing time "){
Echo "happy new year ";
}
Echo $ showtime;
2. zidong. php:
The code is as follows:
Ajax dynamic display time
Current time: