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

ParameterIs RequiredDescription
filenameRequired.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");
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions