加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php源码之检测文件是否可读可写(is_writable is_readable实例)

发布时间:2020-05-25 02:13:52 所属栏目:PHP 来源:互联网
导读:本文章向大家介绍php如何判断文件是否可读可写,主要使用到php的两个函数is_writable和is_readable,需要的朋友可以参考一下本文章的源代码。

php 源码之判断文件是否可读:

Is the file readable: is_readable()

$file = "test.txt";

outputFileTestInfo( $file );

function outputFileTestInfo( $f ){

if ( ! file_exists( $f ) ){

print "$f does not exist
";

return;

}

print "$f is ".(is_readable( $f )?"":"not ")."readable
";

}

?>

php 源码之判断文件是否可写:

Is the file writable: is_writable()

$file = "test.txt";

outputFileTestInfo( $file );

function outputFileTestInfo( $f ){

if ( ! file_exists( $f ) ){

print "$f does not exist
";

return;

}

/* http://www.manongjc.com/article/1370.html */

print "$f is ".(is_writable( $f )?"":"not ")."writable
";

}

?>

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读