PHP filetype() Function

❮ PHP Filesystem Reference

Example

Return the file type for "test.txt":

<?php
echo filetype("test.txt");
?>
Run Example »

Definition and Usage

The filetype() function returns the file type of a file.

Possible return values:

  • fifo
  • char
  • dir
  • block
  • link
  • file
  • socket
  • unknown

Note: The result of this function is cached. Use clearstatcache() to clear the cache.

Syntax

filetype(filename)

Parameter Values

Parameter Description
filename Required. Specifies the file to check


Technical Details

Return Value: One of the file types on success, FALSE on failure
PHP Version: 4.0+

More Examples

Example

Return the file type for /images/:

<?php
echo filetype("/images/");
?>
Run Example »

❮ PHP Filesystem Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.