Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 11:17:49
Original
1257 people have browsed it

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

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

$file = "data.txt";
$dir = "www.bkjia.com/newdata";

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


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!