is_file()
是 PHP 中的一个内置函数,用于检查给定的文件路径是否存在且是一个常规文件
<?php
$file_path = 'path/to/your/file.txt';
if (is_file($file_path)) {
echo "The file exists and is a regular file.";
} else {
echo "The file does not exist or is not a regular file.";
}
?>
在这个示例中,将 $file_path
变量设置为要检查的文件的路径。然后使用 is_file()
函数检查文件是否存在且为常规文件。根据检查结果,输出相应的消息。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:php is_file如何检查