php教程|php手册
删除,复制,文件夹
php教程-php手册
蓝色asp网站模板源码,ubuntu怎么清空arp,tomcat每天0点重启,移动6.5系统爬虫,php文件用什么软件打开运行,成为seo高手lzw
最近写代码,需要个复制文件夹与及其文件夹下所有文件的功能,有时候需要删除,就可以用这个函数了,通过xcopy与deldir的自定义函数,确实方便多了,特分享下
视频编辑软件 源码,ubuntu屏幕闪烁位移,tomcat默认页面重定向,python爬虫最佳数据,php重载和重写的区别,seo的广告lzw
电脑密码源码,vscode怎样安装,双系统电脑重装ubuntu,更换tomcat图标,sqlite3服务,dedecms 下载插件,前端开发免费框架 下载,爬虫文库文档源码,php http 请求,柴潇seo,css 手机网站源码,网页上加滚动图,一个书城的html模板页面,绿色页面的小说网站模板下载地址,车辆租赁管理系统php代码,砍价宝小程序前端 后端微擎开源lzw
代码如下:
<?php
/*复制xCopy函数用法:
* xCopy(“feiy”,”feiy2″,1):拷贝feiy下的文件到 feiy2,包括子目录
* xCopy(“feiy”,”feiy2″,0):拷贝feiy下的文件到 feiy2,不包括子目录
*参数说明:
* $source:源目录名
* $destination:目的目录名
* $child:复制时,是不是包含的子目录
*/
function xCopy($source, $destination, $child){
if (!file_exists($destination))
{
if (!mkdir(rtrim($destination, ‘/’), 0777))
{
//$err->add($_LANG[‘cannt_mk_dir’]);
return false;
}
@chmod($destination, 0777);
}
if(!is_dir($source)){
return 0;
}
if(!is_dir($destination)){
mkdir($destination,0777);
}
$handle=dir($source);
while($entry=$handle->read()){
if(($entry!=”.”)&&($entry!=”..”)){
if(is_dir($source.”/”.$entry)){
if($child)
xCopy($source.”/”.$entry,$destination.”/”.$entry,$child);
}
else{
copy($source.”/”.$entry,$destination.”/”.$entry);
}
}
}
return 1;
}
/*删除deldir函数用法:
* deldidr(“feiy”):删除feiy,包括子目录
*参数说明:
* $dir:要删除的目录名
*/
function deldir($dir) {
if (!file_exists($dir)){return true;
}else{@chmod($dir, 0777);}
$dh=opendir($dir);
while ($file=readdir($dh)) {
if($file!=”.” && $file!=”..”) {
$fullpath=$dir.”/”.$file;
if(!is_dir($fullpath)) {
unlink($fullpath);
} else {
deldir($fullpath);
}
}
}
closedir($dh);
if(rmdir($dir)) {
return true;
} else {
return false;
}
}
?>