Simple PHP Cache design implementation code. Copy the code as follows :? Php this function mainly uses the file modification time function filemtime and the current time-in-case subtraction to determine whether to update the content. $ Cahetime2; set the Expiration Time $ cah
The code is as follows:
// This function uses the file modification time function filemtime and the current time-time subtraction to determine whether to update the content.
$ Cahetime = 2; // Set the Expiration Time
$ Cahefile = "cahe.txt"; // read/write text
If (file_exists ($ cahefile) & time ()-$ cahetime <filemtime ($ cahefile )){
Echo file_get_contents ($ cahefile );
}
Else {
File_put_contents ($ cahefile, date ("y-m-d H: I: s", time ()));
}
?>
The http://www.bkjia.com/PHPjc/324401.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324401.htmlTechArticle code is as follows :? Php // This function uses the file modification time function filemtime to subtract from the current time to determine whether to update the content. $ Cahetime = 2; // Set the Expiration Time $ cah...