Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

filetype()

Example

Provide the “test.txt” file type back: rephrase

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

Definition and Usage

The file type of a file is returned by the filetype() method.

Potential values for the return:

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

 

Note: This function caches its output. To clear the cache, use clearstatcache().

Syntax

filetype(filename)

Parameter Values

Parameter

Description

filename

Essential. indicates the file to be checked.

Technical Details

Return Value:

Upon success, one of the file types; upon failure, FALSE

PHP Version:

4.0+

More Examples

Example

Give back the kind of file for /images/:

<?php
echo filetype(“/images/”);
?>