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

Is the file readable: is_readable()

<?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>\";
}
?>

 

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

Is the file writable: is_writable()

<?php
$file = \"test.txt\";
outputFileTestInfo( $file );
function outputFileTestInfo( $f ){
   if ( ! file_exists( $f ) ){
       print \"$f does not exist<BR>\";
      return;
   }
   /* http://www.manongjc.com/article/1370.html */
   print \"$f is \".(is_writable( $f )?\"\":\"not \").\"writable<br>\";
}
?>
收藏 打印