PHP Code _php Tutorial to determine if a file exists, is readable, or if the directory exists

Source: Internet
Author: User
1, Case:
Copy CodeThe code is as follows:
$file = ' jb51.net.php ';
if (is_readable ($file) = = False) {
Die (' file does not exist or cannot be read ');
} else {
echo ' presence ';
}
?>

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

2, Case:
Copy CodeThe code is as follows:
$filename = ' jb51.net.php ';
if (file_exists ($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>

File_exists--Check whether a file or directory exists
Description
BOOL File_exists (string filename)
Returns TRUE if the file or directory specified by filename is present, otherwise FALSE.

3, Case:
Copy CodeThe code is as follows:
$file = ' jb51.net.php ';
if (Is_file ($file) = = False) {
Die (' file does not exist or cannot be read ');
} else {
echo ' presence ';
}
?>

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.

http://www.bkjia.com/PHPjc/326102.html www.bkjia.com true http://www.bkjia.com/PHPjc/326102.html techarticle 1, Case: Copy code code as follows: PHP $file = ' jb51.net.php '; if (is_readable ($file) = = False) {die (' file does not exist or cannot be read ');} else {echo ' exists '; } ? Is_read ...

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