PHP Bulk emptying deletes the contents of the specified folder

Source: Internet
Author: User
<span id="Label3"></p><p><p>PHP Bulk emptying deletes the contents of the specified folder:</p></p><p><p><strong><span style="color: #ff0000;">cleancache.php</span></strong></p></p><pre class="cnblogs_Highlighter brush:php;"><pre class="cnblogs_Highlighter brush:php;"><?php//file Cache $dirs = array (realpath (dirname (__file__). ‘/.. /data/cache_data '), Realpath (dirname (__file__). ‘/.. /data/cache_file '), Realpath (dirname (__file__). ‘/.. /data/cache_view ');//clean cache foreach ($dirs as $dir) {do_rmdir ($dir, false); echo "<div style= ' border:2px solid green; Background: #f1f1f1; padding:20px;margin:20px;width:800px;font-weight:bold;color:green;text-align:center; ' >\ "". $dir. "\" has been cleaned clear! </div> ";} /** * Empty/delete folder * @param string $dirname folder path * @param bool $self Whether to delete the current folder * @return bool */function do_rmdir ($dirname, $self = True) {if (!file_exists ($dirname)) {return false;} If (is_file ($dirname) | | is_link ($dirname)) {return unlink ($dirname);} $dir = dir ($dirname), if ($dir) {while (false!== $entry = $dir->read ()) {if ($entry = = '. ' | | $entry = = ' ... ') {continue;} Do_rmdir ($dirname. ‘/‘ . $entry);}} $dir->close (); $self && rmdir ($dirname);}</pre></pre><p><p>PHP Bulk emptying deletes the contents of the specified folder</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.