PHP filetype() Function
In this chapter you will learn:
- Definition for PHP filetype() Function
- Syntax for PHP filetype() Function
- Parameter for PHP filetype() Function
- Return for PHP filetype() Function
- Note for PHP filesize() Function
- Example - returns the file type of a specified file or directory
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/* j a v a 2 s . c o m*/
echo filetype("test.txt");
echo "\n";
echo filetype("images");
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP flock() Function
- Syntax for PHP flock() Function
- Parameter for PHP flock() Function
- Return for PHP flock() Function
- Example - Lock a file
- Example - Lock a file and write a string to it
Home » PHP Tutorial » PHP File Functions