Is_dir () function user guide in PHP _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP is_dir () function User Guide. In PHP, the is_dir () function usage guide php provides the built-in function is_dir to check whether the input path parameter is a directory. if it is a directory, true is returned. That is to say, the input parameters are files or is_dir () function usage instructions in PHP.

Php provides the built-in function is_dir to check whether the input path parameter is a directory. if it is a directory, true is returned. That is to say, if the input parameter is a file or does not exist, it is false. Therefore, the current parameter cannot be used as a folder or a file. In addition, you must note that parameters support relative paths and absolute paths.

Function: is_dir ()

Function: determines whether the specified file name is a directory.

Note:

Bool is_dir (string $ filename)

Returns TRUE if the file name exists and is a directory.

If filename is a relative path, check its relative path according to the current working directory.

Note: the result of this function is cached. For more information, see clearstatcache ().

Example 1

?

1

2

3

4

5

Var_dump(is_dir('a_file.txt '). "\ n ";

Var_dump (is_dir ('bogus _ dir/ABC'). "\ n ";

Var_dump (is_dir ('..'); // one dir up

?>

The above example will output:

Bool (false)

Bool (false)

Bool (true)

Example 2

?

1

2

3

4

5

6

7

8

9

10

11

$ File = "images ";

If (is_dir ($ file ))

{

Echo ("$ file is a directory ");

}

Else

{

Echo ("$ file is not a directory ");

}

?>

Output:

If the images directory exists, the output is:

Images is a directory

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

Usage () function guide php provides the built-in function is_dir to check whether the input path parameter is a directory. if it is a directory, true is returned. That is to say, the input parameter is a file or not...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.