The file_exists function is a simple function you will use again and again if you use filesystem functions at all. It simply checks the local filesystem for a file of the specified name.
Quoteif (!file_exists("testfile.php")) {
$fd = fopen("testfile.php", "w+");
}
The function returns true if the file exists, false if not found. The results of this test are stored in a cache, which may be cleared by use of the function clearstatcache().