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

is_file()

Example

Verify if the filename provided is a normal file

<?php
$file = “test.txt”;
if(is_file($file)) {
  echo (“$file is a regular file”);
else {
  echo (“$file is not a regular file”);
}
?>

What the code above might produce is:

test.txt is a regular file

Definition and Usage

The method is_file() determines if the given filename is a regular file or not.

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

Syntax

is_file(file)

Parameter Values

 

Parameter

Description

file

Essential. gives the location of the file to be checked.

Technical Details

Return Value:

If the file is a regular file, then TRUE; if not, then FALSE

PHP Version:

4.0+