PHP filetype() Function
Definition
The filetype() function returns the file type of a specified file or directory.
Syntax
PHP filetype() Function has the following syntax.
filetype(filename)
Parameter
Parameter | Is Required | Description |
filename | Required. | File to check |
Return
This function returns the one of seven possible values on success or FALSE on failure.
Possible return values:
- fifo
- char
- dir
- block
- link
- file
- unknown
Note
The result of this function are cached. Use clearstatcache() to clear the cache.
Example
Returns the file type of a specified file or directory
<?php//from ww w . ja v a2s . c om
echo filetype("test.txt");
echo "\n";
echo filetype("images");
?>