How to determine directory or file in php

藏色散人
Release: 2023-03-02 11:58:01
Original
2875 people have browsed it

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;
Copy after login
Copy after login

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;
Copy after login
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!