PHP is the code that determines if a file exists if it is readable and if a directory exists
- 2020-05-26 07:53:27
- OfStack
1. Case:
<?php
$file = 'ofstack.com.php';
if (is_readable($file) == false) {
die(' The file does not exist or cannot be read ');
} else {
echo ' There are ';
}
?>
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. Cases:
<?php
$filename = 'ofstack.com.php';
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
file_exists -- check to see if a file or directory exists
instructions
bool file_exists ( string filename )
Returns TRUE if the file or directory specified by filename exists, otherwise returns FALSE.
3. Case:
<?php
$file = 'ofstack.com.php';
if (is_file($file) == false) {
die(' The file does not exist or cannot be read ');
} else {
echo ' There are ';
}
?>
is_file -- determines whether a given file name is a normal file
instructions
bool is_file ( string filename)
Returns TRUE if the file exists and is a normal file.