1,php判断文件是否可读,is_readable()的例子。
复制代码 代码示例:
<html>
<head>
<title>is_readable()判断文件是否可读-www.jb200.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_readable( $f )?"":"not ")."readable<br>";
}
?>
</body>
</html>
2,判断文件是否有可写权限,is_writable()的例子。
复制代码 代码示例:
<html>
<head>
<title>is_writable()检测文件是否可写-www.jb200.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_writable( $f )?"":"not ")."writable<br>";
}
?>
</body>
</html>
相关阅读: