Home  >  Article  >  Backend Development  >  How to determine whether it is a file or a directory in php

How to determine whether it is a file or a directory in php

王林
王林Original
2020-08-04 13:19:172826browse

How to determine whether it is a file or a directory in php: You can use the is_file() function and is_dir() function to determine. The is_file() function checks whether the specified file is a regular file and returns true if so. The is_dir() function checks whether the specified file is a directory and returns true if so.

How to determine whether it is a file or a directory in php

In PHP, determining whether a file or folder is a file is mainly achieved by using the is_file() and is_dir() functions.

(Recommended tutorial: php graphic tutorial)

PHP is_file() function checks whether the specified file is a regular file. Returns true if it is, false otherwise.

Syntax:

is_file(file)

file: required. Specifies the file or path to be checked.

Code implementation:

How to determine whether it is a file or a directory in php

(Video tutorial recommendation: php video tutorial)

php is_dir() function Checks whether the specified file is a directory, returns true if it is, otherwise returns false.

Syntax:

is_dir(file)

file: required. Specifies the documents to be checked.

Code:

How to determine whether it is a file or a directory in php

The above is the detailed content of How to determine whether it is a file or a directory in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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