• PHP Video Tutorials

PHP - Function filetype()



The filetype() function can return the file type of a specified file or directory. This function can return one of seven possible values on success or false on failure.

Syntax

string filetype ( string filename )

The possible values are fifo, char, dir, block, link, file, and unknown.

The filetype() can also produce an E_NOTICE message if the stat call fails or if the file type is unknown.

Example

<?php
   echo filetype("/PhpProject/sample.txt");  // file
   echo "\n";
   echo filetype("/PhpProject/");  // dir
?>

Output

file
dir
php_function_reference.htm
Advertisements