PHP code to determine whether the file exists, whether it is readable, and whether the directory exists_PHP tutorial

WBOY
Release: 2016-07-21 15:15:23
Original
862 people have browsed it

1. Case:

Copy code The code is as follows:

$file = ' jb51.net.php';
if (is_readable($file) == false) {
die('The file does not exist or cannot be read');
} else {
echo 'Exists ';
}
?>

is_readable() function determines whether the specified file name is readable.
The specified file or directory exists and is readable, then TRUE is returned

2. Case:
Copy code The 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 the file or directory exists
Description
bool file_exists ( string filename )
If by filename Returns TRUE if the specified file or directory exists, otherwise returns FALSE.

3. Case:
Copy code The code is as follows:

$file = 'jb51.net.php';
if (is_file($file) == false) {
die('The file does not exist or cannot be read');
} else {
echo 'exists';
}
?>

is_file -- Determine whether 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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326102.htmlTechArticle1. Case: Copy the code as follows: ?php $file = 'jb51.net.php'; if ( is_readable($file) == false) { die('The file does not exist or cannot be read'); } else { echo 'exists'; } ? is_read...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!