$filename = "/path/to/file.txt"; if (is_readable($filename)) { echo "The file $filename is readable."; } else { echo "The file $filename is not readable."; }
$directory = "/path/to/directory"; if (is_readable($directory)) { $files = scandir($directory); foreach ($files as $file) { echo $file . "In this example, we check if the directory at "/path/to/directory" is readable. If it is, we use the PHP function "scandir()" to get a list of files in the directory and output them. The "is_readable()" function is part of PHP's core library, so no additional package or library is necessary.
"; } } else { echo "The directory $directory is not readable."; }