PHP file_exists() Function

Definition and Usage

The file_exists() function checks if the file or directory exists.

Returns true if the specified file or directory exists, otherwise returns false.

Syntax

file_exists(path)
Parameter Description
path Required. Specifies the path to check.

Example

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

Output:

1