filetype

string filetype(string filename) 

Retrieves the file type.

Returns:

File type; FALSE on error

Description:

Returns the generic type of the specified file. The information is not as detailed as the UNIX file command.

The available file types are block, char, dir, fifo, file, link, and unknown. The dir, file, and link types correspond to directories, files, and hard or soft links. The block, char, and fifo types refer to various types of devices. Please refer to your system documentation for more details.

Note:

The results of this function are cached. See clearstatcache() for details.

Example:

Print a file type
$filetype = filetype("myfile"); 
echo ($filetype); 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.