is_file

bool is_file(string filename) 

Checks whether a file is a regular file.

Returns:

TRUE if a regular file; FALSE otherwise

Description:

Checks whether the specified file is a normal file as opposed to a directory or link.

Note:

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

Example:

Test for a regular file
$file = "testfile"; 

if(is_file($file)) 
{
    echo ("$file is a normal file."); 
} 
else 
{
    echo ("$file could be a link or dir."); 
} 

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.