php中目录操作函数(删除,创建,判断)
本文章主要是介绍在php目录操作函数 is_dir,rd_dir,mkdir等常用的目录操作函数实例介绍。
本文章主要是介绍在php教程目录操作函数 is_dir,rd_dir,mkdir等常用的目录操作函数实例介绍。
*/
function dir_writeable($dir) //自定义函数扩展功能,建立可写的目录
{
if(!is_dir($dir)) //如果给定的参数不是目录
{
@mkdir($dir,0777); //创建目录
echo "目录".$dir."建立成功!";
}
}
dir_writeable("test"); //调用自定义函数,建立test目录
/*
执行本代码将会在当前目录建立名为:test的目录,同时将输出:
目录test建立成功
*/
$dir="test"; //定义目录
if(rmdir($dir)) //如果成功删除目录
{
echo "目录".$dir."被成功删除!"; //输出内容
}
else
{
echo "删除目录".$dir."时,出现错误!";
}
//
$path="test.txt"; //定义路径
echo $path; //输出处理前的
$realpath=realpath($path); //将指定绝对路径规范化输出
echo "
";
echo $realpath //输出处理后的结果
//看一完整理实例
function dir_writeable($dir) //建立自定义函数扩展功能
{
if(!is_dir($dir)) //如果给定参数不是目录
{
@mkdir($dir,0777); //创建目录
}
if(is_dir($dir))
{
if($fp=@fopen("$dir/test.txt",'w')) //以写方式打开指定路径下的文件,如果不存在就创建
{
@fclose($fp); //关闭文件句柄
@unlink("$dir/test.txt"); //删除文件
$writeable=1; //定义返回值为真
}
else
{
$writeable=0; //定义返回值为假
}
}
return $writeable; //返回值
} //自定义函数结束

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software