The file_exists function checks whether a file or directory exists.

    
    $filename = '/path/to/foo.txt';

    $fileExists = file_exists($filename);

    echo $fileExists;
    // 1