教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php判断文件是否可读与可写的代码

php判断文件是否可读与可写的代码

发布时间:2017-01-17   编辑:jiaochengji.com
本文分享二个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>

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>
相关阅读:
php判断文件是否存在、是否可读、目录是否存在

您可能感兴趣的文章:
php判断文件是否可读与可写的代码
php用于判断文件是否存在、是否可读、目录是否存在的代码
判断对文件空目录是否有读写权限的php代码
php 读取目录文件夹列表的例子
php中删除文件用unlink函数权限判断
检查文件与目录存在与否的php代码
使用php判断文件是否存在、是否可读、目录是否存在
php根据文件头判断文件类型的代码分享
php文件操作之读取与写入文件
使用php的zlib压缩和解压缩swf文件的代码

[关闭]
~ ~