file_exists

bool file_exists(string filename) 

Determines whether a file exists.

Returns:

TRUE if the file exists; FALSE on error

Description:

Checks for the existence of a file. It’s a good idea to use this function before other filesystem functions to ensure that the file you need actually exists.

Note:

The results of this function are cached. See clearstatcache() for details.

Example:

Test whether a file exists
if(!file_exists("myfile")) 
{
    echo ("File not found"); 
} 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.