PHP determines whether a file or directory exists_PHP tutorial

WBOY
Release: 2016-07-20 11:01:18
Original
1137 people have browsed it

PHP has a very simple method to determine whether a file or directory exists. PHP has its own function to determine whether a file or directory exists. File_exists file exists. To determine whether a directory exists, we can use is_dir. ​

php tutorial to determine whether a file or directory exists
The method is very simple. PHP has its own function to determine whether a file or directory exists. File_exists file exists. To determine whether a directory exists, we use is_dir and it is ok.
*/

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

if(file_exists($file))
{
echo "In the current directory, the file ".$file." exists";
echo "
";
}
else
{
echo "The file ".$file." does not exist in the current directory";
echo "
";
}
echo "
";
echo "


";
echo "
";

if(is_dir($dir))
{
echo "Under the current directory, the directory ".$dir." exists";
echo "
";
}
else
{
echo "Under the current directory, the directory ".$dir." does not exist";
echo "
";
}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445442.htmlTechArticlephp The method to determine whether a file or directory exists is very simple. PHP has its own function to determine whether a file or directory exists. file_existsWhether the file exists, to determine whether the directory exists we use is_...
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