This article describes the file_exists function used in php to determine whether a file or directory exists. It is attached with several classic examples. For more information, see. Note:
Bool file_exists (string $ filename)
If a file or directory specified by filename exists, TRUE is returned; otherwise, FALSE is returned.
In Windows, use // computer name/shared/file name or computer name shared file name to check network shared files.
In Windows, use // computername/share/filename or \ computername \ share \ filename to check shared files in the network.
Instance 1
<? Php $ filename = '/php.net/aa/to/foo.txt'{if (file_exists ($ filename) {echo "File $ filename exists";} else {echo "File $ filename does not exist";}?>
Output result:
File/php.net/aa/to/foo.txtexists
Instance 2
<? Phpecho file_exists ("php.net.txt");?>
Use file_exists to return true or false.
The above is all the content of this article. I hope you will like it.