Home >php教程 >php手册 >技巧分享 PHP删除复制文件

技巧分享 PHP删除复制文件

WBOY
WBOYOriginal
2016-06-13 11:11:24862browse

  1.  ?PHP  
  2. $file = 'dirlist.PHP';  
  3. $result = @unlink ($file);  
  4. if ($result == false) {  
  5. echo '蚊子赶走了';  
  6. } else {  
  7. echo '无法赶走';  
  8. }  
  9. ?> 

即可.

PHP删除复制文件中的复制文件同样也很容易:

<ol class="dp-xml">
<li class="alt"><span class="tag"> ?PHP  </span></li>
<li>
<span>$</span><span class="attribute">file</span><span> = </span><span class="attribute-value">'yang.txt'</span><span>;  </span>
</li>
<li class="alt">
<span>$</span><span class="attribute">newfile</span><span> = </span><span class="attribute-value">'ji.txt'</span><span>; # <br>这个文件父文件夹必须能写  </span>
</li>
<li><span>if (file_exists($file) == false) {  </span></li>
<li class="alt"><span>die ('小样没上线,无法复制');  </span></li>
<li><span>}  </span></li>
<li class="alt">
<span>$</span><span class="attribute">result</span><span> = </span><span class="attribute-value">copy</span><span>($file, $newfile);  </span>
</li>
<li>
<span>if ($</span><span class="attribute">result</span><span> == false) {  </span>
</li>
<li class="alt"><span>echo '复制记忆ok';  </span></li>
<li><span>}  </span></li>
<li class="alt">
<span class="tag">?></span><span> </span>
</li>
</ol>

以上就是PHP删除复制文件的相关技巧总结。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn