filetype() function in PHP


The filetype() function returns the file type of a file or directory. On success, the filetype() function returns one of the following values −

  • fifo
  • char
  • dir (directory)
  • block
  • link (symbolic link)
  • file
  • unknown (this is an unknown file type)

Syntax

filetype(file_path)

Parameters

  • file_path − The path of the file for which we want the filetype.

Return

The filetype() function returns file type of a file or directory on success, else it returns FALSE on failure.

Example

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

Output

file

Let us see another example.

Example

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

Output

directory

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 24-Jun-2020

58 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements