Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to clear the cache by thinkphp

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "how to clear the cache in thinkphp". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Thinkphp implementation clears cache

Dedecms has the function to clear the cache, so I made great efforts to study it. As a result, I was in a fog, hi. As a result, I checked it on the Internet and wrote a cache removal function according to the website.

Tp executes the code:

/ / is to get the directory and the absolute path where the directory is located, public function cache () {/ the foreground submits it by ajax get. Here is to judge the if ($_ POST ['type']) {/ / get the passed value $type=$_POST [' type']; / / to cut the passed value. I am the $name=explode ('-', $type) that has been "-" cut. / / get the number of cut entries, so that you can cycle around $count=count ($name); / / call the above method for ($pa,$name [$I]);} / / give the prompt $this- > ajaxReturn (1 'cleared successfully', 1);} else {$this- > display () }} public function rmFile ($path,$fileName) {/ / delete the executed method / / remove spaces $path = preg_replace ('/ (\ /) {2,} | {1,} /','/', $path); / / get the complete directory $path.= $fileName / / determine whether this file is a file directory if (is_dir ($path)) {/ / Open file if ($dh = opendir ($path)) {/ / traversal file directory name while (($file = readdir ($dh))! = false) {/ / delete unlink ($path.'\\'. $file) one by one;} / / close the file closedir ($dh) } tp: foreground code (a little crude)-- > this is the end of the content of "how to clear the cache with thinkphp". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report