php判断文件是否可读与可写的代码
发布时间:2017-01-17 编辑:www.jquerycn.cn
本文分享二个php的实例代码,学习下is_readable()与is_writable()的用法,判断指定的文件是否可读或可写。有需要的朋友参考下。
1,php判断文件是否可读,is_readable()的例子。
复制代码 代码示例:
<html>
<head>
<title>is_readable()判断文件是否可读-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_readable( $f )?"":"not ")."readable<br>";
}
?>
</body>
</html>
<head>
<title>is_readable()判断文件是否可读-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_readable( $f )?"":"not ")."readable<br>";
}
?>
</body>
</html>
2,判断文件是否有可写权限,is_writable()的例子。
复制代码 代码示例:
<html>
<head>
<title>is_writable()检测文件是否可写-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_writable( $f )?"":"not ")."writable<br>";
}
?>
</body>
</html>
相关阅读:
<head>
<title>is_writable()检测文件是否可写-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_writable( $f )?"":"not ")."writable<br>";
}
?>
</body>
</html>
php判断文件是否存在、是否可读、目录是否存在
您可能感兴趣的文章:
[关闭]