How to Use the file_exists function in php _ php instance

Source: Internet
Author: User
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 = '/'{if (file_exists ($ filename) {echo "File $ filename exists";} else {echo "File $ filename does not exist";}?>

Output result:

Instance 2

<? Phpecho file_exists ("");?>

Use file_exists to return true or false.

The above is all the content of this article. I hope you will like it.

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: 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.