Home > Backend Development > PHP Tutorial > Development process and example sharing of php file directory operations

Development process and example sharing of php file directory operations

黄舟
Release: 2023-03-15 11:14:01
Original
1864 people have browsed it

We often encounter operations such as generating file directories and editing files (folders). Today I will introduce to you a file directory operation class in PHP, which can create directories, delete directories, create files, delete files, move folders, and copy Folders and a series of functions you can operate.

First download the file directory operation library in PHP that we need to use in this course: //m.sbmmt.com/xiazai/leiku/544

Find after the download is complete Unzip the php class file we need to our local directory and create a new php file!

After completion, we need to call this class in the new php file and instantiate the class:

<?php

include_once "caozuo1.php";                //引入类文件
$obj = new FileUtil;                       //实例化类
$obj->createDir(&#39;a/1/2/3&#39;);                //测试建立文件夹 建一个a/1/2/3文件夹
$obj->createFile(&#39;b/1/2/3&#39;);               //测试建立文件        在b/1/2/文件夹下面建一个3文件
$obj->createFile(&#39;b/1/2/3.exe&#39;);           //测试建立文件        在b/1/2/文件夹下面建一个3.exe文件
$obj->copyDir(&#39;b&#39;,&#39;d/e&#39;);                  //测试复制文件夹 建立一个d/e文件夹,把b文件夹下的内容复制进去
$obj->copyFile(&#39;b/1/2/3.exe&#39;,&#39;b/b/3.exe&#39;); //测试复制文件        建立一个b/b文件夹,并把b/1/2文件夹中的3.exe文件复制进去
$obj->moveDir(&#39;a/&#39;,&#39;b/c&#39;);                 //测试移动文件夹 建立一个b/c文件夹,并把a文件夹下的内容移动进去,并删除a文件夹
$obj->moveFile(&#39;b/1/2/3.exe&#39;,&#39;b/d/3.exe&#39;); //测试移动文件        建立一个b/d文件夹,并把b/1/2中的3.exe移动进去
$obj->unlinkFile(&#39;b/d/3.exe&#39;);             //测试删除文件        删除b/d/3.exe文件
$obj->unlinkDir(&#39;d&#39;);                      //测试删除文件夹 删除d文件夹
?>
Copy after login

Note: The result page display of this run will be Blank:

Development process and example sharing of php file directory operations

##But in our local I can find the file directory All have been created, as shown below:

Development process and example sharing of php file directory operations


##

The above is the detailed content of Development process and example sharing of php file directory operations. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template