In the previous course, we introduced the development ideas and examples of php cache usage. Friends who have watched the previous courses should know that cache processing is helpful to the execution efficiency of the program. , the php cache class can be used to detect whether the file is within the set update time, clear cache files, generate cache file names based on the current dynamic files, and create directories. Cache file output and other functions~
So today we will continue to introduce the development of php cache to you. Today we are going to introduce an example of php cache multi-level directory. In the first step, we also need to download the file we use. The php cache class reached:
http://www.php.cn/xiazai/leiku/700
Next we unzip the downloaded file to our In the local editor, OK, and then create a new php file to call this class:
<?php include_once "codehuancun.php"; $cache = new php_cache('index'); //缓存二级目录 $cache = new php_cache('index',1800); //缓存时间 默认1800 $cache = new php_cache('index',1800,1); //是否需要三级目录 0:不需要 1 需要 默认0 $cache = new php_cache('index',1800,1,'.html');//缓存后缀 默认 .html ?>
This is to give you a better explanation, so the code is separated step by step. In fact, All you need is the last line of code and you’re done!
Finally we run this php file, and then the page has no data, but a directory is created in the local server:
The above is the detailed content of Development example of php caching multi-level directories. For more information, please follow other related articles on the PHP Chinese website!