How does php determine whether the path is a folder or a file
This article mainly shows you the "php how to determine the path is a folder or a file", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "php how to determine the path to a folder or a file" this article.
In php, you can use if statements and is_dir () and is_file () functions to determine whether the path is a folder or a file. The syntax "if (is_dir ($file)) {echo" is a folder;} else if (is_file ($file)) {echo "is a file".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php determines whether the path is a folder or a file
In php, you can use if statements and is_dir () and is_file () functions to determine whether the path is a folder or a file.
The is_dir () function checks whether the specified file is a directory. This function returns TRUE if the directory exists.
The is_file () function checks whether the specified file is a regular file. This function returns TRUE if the file is a regular file.
Implementation code:
Output result:
If you change the value of $file to "img", you will output:
The above is all the contents of the article "how php determines whether the path is a folder or a file". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!