Приглашаем посетить
Html (html.find-info.ru)

Section 13.5.  Checking Whether a File Exists

Previous
Table of Contents
Next

13.5. Checking Whether a File Exists

The act of checking whether a file exists is one of the most basic file-related tasks you'll want to do, and file_exists( ) makes it as easy as it should be. Specify the filename to check as the only parameter, and it returns true if the file exists and false otherwise. For example:

    if (file_exists("snapshot1.png")) {
            print "Snapshot1.png exists!\n";
    } else {
            print "Snapshot1.png does not exist!\n";
    }

Section 13.5.  Checking Whether a File Exists

The result of file_exists( ) is cached, which means you first need to call the clearstatcache( ) function if you want to be absolutely sure a file exists.



Previous
Table of Contents
Next