PHP file_exists() Function

❮ PHP Filesystem Reference

Example

Check whether a file exists:

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

Definition and Usage

The file_exists() function checks whether a file or directory exists.

Note: The result of this function is cached. Use clearstatcache() to clear the cache.

Syntax

file_exists(path)

Parameter Values

Parameter Description
path Required. Specifies the path to the file or directory to check


Technical Details

Return Value: TRUE if the file or directory exists, FALSE on failure
PHP Version: 4.0+

❮ PHP Filesystem Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.