Latest web development tutorials

PHP filetype () function

PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual

Definition and Usage

filetype () function returns the specified file or directory type.

If successful, the function returns one of the possible values ​​of seven kinds. If it fails, it returns FALSE.

The possible return values:

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

grammar

filetype(filename)

参数 描述
filename 必需。规定要检查的文件。


Tips and Notes

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


Example 1

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

The code above will output:

file


Example 2

<?php
echo filetype("images");
?>

The code above will output:

dir


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual