← All built-ins / file_exists()

file_exists()

file_exists(string $s): bool

Parameters

NameTypeDescription
$pathstringfile or directory path

Return value

true when the path exists.

Example

file_put_contents("/tmp/hphp_doc_e.txt", "x");
var_dump(file_exists("/tmp/hphp_doc_e.txt"));
var_dump(file_exists("/tmp/hphp_doc_missing.xyz"));
unlink("/tmp/hphp_doc_e.txt");
bool(true)
bool(false)

See also

is_file()is_dir()filesize()