首页 > php函数 > php 判断文件或目录是否存在

php 判断文件或目录是否存在

php 判断文件或目录是否存在方法很简单的php 判断文件或目录是否存在有自带的函数,file_exists文件是否存在,判断目录是否存在我们用is_dir就OK了。

 

php教程 判断文件或目录是否存在
方法很简单的php 判断文件或目录是否存在有自带的函数,file_exists文件是否存在,判断目录是否存在我们用is_dir就ok了。
*/

$file = "data.txt";
$dir = "php教程";

if(file_exists($file))
{
    echo "当前目录中,文件".$file."存在";
    echo "
";
}
else
{
     echo "当前目录中,文件".$file."不存在";
     echo "
";
}
echo "
";
echo "



";
echo "
";

 

if(is_dir($dir))
{
    echo "当前目录下,目录".$dir."存在";
    echo "
";
}
else
{
     echo "当前目录下,目录".$dir."不存在";
     echo "
";
}


文章网址:http://www.phprm.com/function/php1004535.html

随意转载^^但请附上教程地址。

标签:none

发表留言