Home >Backend Development >PHP Problem >How to determine directory or file in php

How to determine directory or file in php

藏色散人
藏色散人Original
2020-07-11 10:47:353055browse

php method to determine whether a directory is a file: 1. Use the "is_file()" function to determine whether it is a file, and the return result is true or false; 2. Use the "is_dir()" function to determine whether it is a directory , the return result is true or false.

How to determine directory or file in php

php determines whether a file or a folder is mainly determined by the is_file and is_dir functions, which are explained below:

is_file() function

is_file() function is used to determine whether it is a file, and the return result is true or false

Example:

$ifile="c:/test";
$result=is_file($ifile);
echo $result;

Output: false

is_dir() function

is_dir() function is used to determine whether it is a directory. The return result is true or false

Example:

$ifile="c:/test";
$result=is_file($ifile);
echo $result;

Output: true

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to determine directory or file 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