In PHP, you can use the is_dir() function to determine whether it is a folder. The function of this function is to check whether the specified file is a directory (folder), the syntax is "is_dir(file)"; if If it is a folder, TRUE is returned.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use the is_dir() function to determine whether it is a folder.
is_dir() function checks whether the specified file is a directory. Syntax:
is_dir(file)
file: required parameter, specifies the file to be checked.
If the directory exists, this function returns TRUE.
Example: Determine whether the img file is a folder
<?php header("Content-type:text/html;charset=utf-8"); $file = "img"; if(is_dir($file)) { echo ("$file 是文件夹"); } else { echo ("$file 不是文件夹"); } ?>
Output result:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to determine if it is a folder in php. For more information, please follow other related articles on the PHP Chinese website!