php判断是否为文件(is_file())或目录(is_dir())的实例代码
1,php检测变量是否为一个文件,is_file()的用法举例。
<head>
<title>is_file()判断是否为文件-www.jbxue.com</title>
</head>
<body>
<?php
$file = "test.txt";
outputFileTestInfo( $file );
function outputFileTestInfo( $f ){
if ( ! file_exists( $f ) ){
print "$f does not exist<BR>";
return;
}
print "$f is ".(is_file( $f )?"":"not ")."a file<br>";
}
?>
</body>
</html>
2,php检测是否为一个目录,is_dir()的用法举例。
<head>
<title>is_dir()检测是否为一个目录-www.jbxue.com</title>
</head>
<body>
<?php
$file = "test.txt";
outputFileTestInfo( $file );
function outputFileTestInfo( $f ){
if ( ! file_exists( $f ) ){
print "$f does not exist<BR>";
return;
}
print "$f is ".(is_dir( $f )?"":"not ")."a directory<br>";
}
?>
</body>
</html>
您可能感兴趣的文章:
php判断是否为文件(is_file())或目录(is_dir())的实例代码
file_exists与is_file、is_dir的区别
php file_exists is_file与is_dir函数的区别分析
php中is_file与file_exists的区别
php 判断文件存在与否的函数选择(file_exists or is_file)
PHP中file_exists与is_file,is_dir的区别
PHP is_file、file_exists、is_dir总结
php中is_file和file_exists与is_dir的区别
判断对文件空目录是否有读写权限的php代码
php用于判断文件是否存在、是否可读、目录是否存在的代码