PHP filetype()Function
Complete PHP Filesystem Reference
Definition and Usage
The filetype() function returns the type of the specified file or directory.
If successful, the function returns one of 7 possible values. If it fails, it returns FALSE.
Possible return values:
- fifo
- char
- dir
- block
- link
- file
- unknown
Syntax
filetype(filename)
| Parameter | Description |
|---|---|
| filename | Required. Specifies the file to be checked. |
Tips and Notes
Note:The results of this function are cached. Use clearstatcache() to clear the cache.
Example 1
<?php
echo filetype("test.txt");
?>
echo filetype("test.txt");
?>
The code above will output:
file
Example 2
<?php
echo filetype("images");
?>
echo filetype("images");
?>
The code above will output:
dir
Complete PHP Filesystem Reference Other Extensions