The filetype() function returns the file type of a file or directory. On success, the filetype() function returns one of the following values −
- fifo
- char
- dir (directory)
- block
- link (symbolic link)
- file
- unknown (this is an unknown file type)
Syntax
filetype(file_path)
Parameters
file_path − The path of the file for which we want the filetype.
Return
The filetype() function returns file type of a file or directory on success, else it returns FALSE on failure.
Example
<?php echo filetype("amit.txt"); ?>
Output
file
Let us see another example.
Example
<?php echo filetype("docs"); ?>
Output
directory