PHP file_exists a function to check whether a file or directory exists _php base

Source: Internet
Author: User
Tags php tutorial
Description
BOOL File_exists (String $filename)

Returns TRUE if the file or directory specified by filename is present, otherwise it returns FALSE.

In fact, PHP tutorial file_exists function and file_exists syntax we've already talked about it, so let's take a look at some of the ways and examples of how it's used.

The file or directory of the path.

On Windows, use the//Computer name/share/file name or computer name to share the file name to check for network shared files.
In Windows, use//computername/share/filename or \\computername\share\filename to check for shared files on your network.

This is a very simple example of a

Copy Code code as follows:

<?php
$filename = '/jb51.net/aa/to/foo.txt ';
if (file_exists ($filename)) {
echo "File $filename exists";
} else {
echo "File $filename does not exist";
}
?>

The output results are:

File/jb51.net/aa/to/foo.txt already exists

Take another look at example two
Copy Code code as follows:

<?php
Echo file_exists ("Jb51.net.txt");
?>

We'll just use file_exists to return ture or false.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.