這篇文章主要介紹了php不使用copy()函數(shù)復(fù)制文件的方法,涉及php讀寫文件的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了php不使用copy()函數(shù)復(fù)制文件的方法。分享給大家供大家參考。具體如下:
下面的代碼不使用php內(nèi)置的copy函數(shù),直接通過文件讀取寫入的操作方式復(fù)制文件
- <?php
- function copyfiles($file1,$file2){
- $contentx =@file_get_contents($file1);
- $openedfile = fopen($file2, "w");
- fwrite($openedfile, $contentx);
- fclose($openedfile);
- if ($contentx === FALSE) {
- $status=false;
- }else $status=true;
- return $status;
- }
- ?>
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答