PHP判断文件或目录是否存在

file_exists() 函数检查文件或目录是否存在。

PHP判断文件或目录是否存在

如果指定的文件或目录存在则返回 true,否则返回 false。

语法

file_exists(path)

示例

<?php
	$filename = '/path/to/foo.txt';
	if (file_exists($filename)) {
		echo "The file $filename exists";
	} else {
		echo "The file $filename does not exist";
	}
?>


本文来源:词雅网

本文地址:https://www.ciyawang.com/php-file-exists-39.html

本文使用「 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 」许可协议授权,转载或使用请署名并注明出处。

相关推荐