Code used by PHP to determine whether a file exists, is readable, and whether the directory exists

Source: Internet
Author: User
    1. $file = ' jbxue.com.php ';
    2. if (is_readable ($file) = = False) {
    3. Die (' file does not exist or cannot be read ');
    4. } else {
    5. echo ' presence ';
    6. }
    7. ?>
Copy Code

The is_readable () function determines whether the specified file name is readable. Returns TRUE if the specified file or directory exists and is readable

Example 2:

    1. $filename = ' jbxue.com.php ';
    2. if (file_exists ($filename)) {
    3. echo "The file $filename exists";
    4. } else {
    5. echo "The file $filename does not exist";
    6. }
    7. ?>
Copy Code

File_exists--Check whether a file or directory exists stating that bool File_exists (string filename) returns TRUE if the file or directory specified by filename is present, otherwise FALSE.

Example 3:

    1. $file = ' jbxue.com.php ';
    2. if (Is_file ($file) = = False) {
    3. Die (' file does not exist or cannot be read ');
    4. } else {
    5. echo ' presence ';
    6. }
    7. ?>
Copy Code

Is_file--Determine if the given file name is a normal file description bool Is_file (string filename) returns TRUE if the file exists and is a normal file.

  • Related Article

    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.