转载于:http://blog.csdn.net/xiao7702/article/details/40406189
一、用途方面
$file = './test.php';
$dir = 'c:/wamp/www/test/';
file_exists($file); //如果文件test.php存在,返回true 反之返回false
file_exists($dir); //如果test目录存在,返回true,返回true 反之返回false
is_file($file); //如果文件test.php存在,返回true 反之返回false
is_file($dir); //无论目录存在否都返回false
二、处理速度方面
测试结果:
当文件存在时:
运行1万次:
is_file–>0.0067121982574463
file_exits–>0.11532402038574
运行10万次:
is_file–>0.069056034088135
file_exits–>1.1521670818329
当运行100万次:
is_file–>0.6924250125885
file_exits–>11.497637987137
当文件不存在时:
运行1万次:
is_file–>0.72184419631958
file_exits–>0.71474003791809
运行10万次:
is_file–>7.1535291671753
file_exits–>7.0911409854889
当运行100万次:
is_file–>72.042867183685
file_exits–>71.789203166962
超过1分钟了,别忘了在php第一行加句:
set_time_limit(120);//时间限制120秒