Home >Backend Development >PHP Tutorial >PHP method example code for copying files without using the copy() function

PHP method example code for copying files without using the copy() function

怪我咯
怪我咯Original
2017-07-10 16:39:561517browse

This article mainly introduces the method of copying files in PHP without using copy() function. It involves the skills of reading and writing files in PHP. It has certain reference value. Friends in need can refer to it

The example in this article describes how to copy files in PHP without using the copy() function. Share it with everyone for your reference. The details are as follows:

The following code does not use PHP's built-in copy function, but directly copies the file through file reading and writing operations

<?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; 
  } 
?>

The above is the detailed content of PHP method example code for copying files without using the copy() function. For more information, please follow other related articles on the PHP Chinese website!

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