Forum und email

file_exists

(PHP 4, PHP 5)

file_exists — Kijkt of een bestand of directorie bestaat

Beschrijving

bool file_exists ( string $filename )

Geeft TRUE terug als het bestand of de directorie aangegeven met filename bestaat; FALSE in alle andere gevallen.

Onder Windows, gebruik //computername/share/filename of \\computername\share\filename om bestanden op gedeelde netwerkmappen te controleren.

Example#1 Testen of een bestand bestaat

<?php
$filename 
'/path/to/foo.txt';

if (
file_exists($filename)) {
    print 
"Het bestand $filename bestaat";
} else {
    print 
"Het bestand $filename bestaat niet";
}
?>

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

Note: This function will not work on remote files as the file to be examined must be accessible via the servers filesystem.

Zie ook is_readable(), is_writable(), is_file() en file().