Guide to using is_dir() function in PHP, guide to using is_dir_PHP tutorial

WBOY
Release: 2016-07-13 09:54:38
Original
977 people have browsed it

Guide to the use of is_dir() function in PHP, guide to the use of is_dir

Function: is_dir()

Function: Determine whether the given file name is a directory

Description:
bool is_dir ( string $filename )

Returns TRUE if the filename exists and is a directory.
If filename is a relative path, its relative path is checked against the current working directory.

Note: The result of this function will be cached. See clearstatcache() for more information.

Example 1

<&#63;
var_dump(is_dir('a_file.txt')) . "\n";
var_dump(is_dir('bogus_dir/abc')) . "\n";
var_dump(is_dir('..')); //one dir up
&#63;>
Copy after login

The above example will output:

bool(false)
bool(false)
bool(true)

Example 2

<&#63;php
$file = "images";
if(is_dir($file))
{
echo ("$file is a directory");
}
else
{
echo ("$file is not a directory");
}
&#63;>
Copy after login

Output:
If the images directory exists, output:
images is a directory

The above is the entire content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/996224.htmlTechArticleUsage Guide of is_dir() function in PHP, is_dir usage guide Function: is_dir() Function: Determine the given file name Whether it is a directory description: bool is_dir ( string $filename ) If the file name...
Related labels:
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