php is_file()函数介绍

is_file — 判断给定文件名是否为一个正常的文件 

语法:

bool is_file  ( string $filename  )

判断给定文件名是否为一个正常的文件。 

参数:

  1. filename 文件的路径。 

返回值:

如果文件存在且为正常的文件则返回 TRUE ,否则返回 FALSE 。

 

php is_file()实例

使用is_file()函数检查文件是否存在,代码如下:

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