|
文件操作的一些总结:
1、is_writable($filename) 判断是否可写
2、is_readable($filename) 判断是否可读
3、写文件
file_put_contents($filename,$content)
$fp = fopen($filename,"w");fwrite($fp,$contents);fclose($fp);
4、读文件
file_read_contents($filename,$content)
$fp = fopen($filename,"r");fread($fp,9999);fclose($fp);
$data = implode('',file($filename));读二进制文件
5、o pendir
-----------
$base_dir = "filelist/";
$fso = opendir($base_dir);
echo $base_dir."<hr/>" ;
while($flist=readdir($fso)){
echo $flist."<br/>" ;
}
closedir($fso)
类:dir
-----------
$d = dir("/etc/php5");
echo "Handle: " . $d->handle . "\n";
echo "Path: " . $d->path . "\n";
while (false !== ($entry = $d->read())) {
echo $entry."\n";
}
$d->close();
6、文件属性
filemtime($file) 返回时间戳
stat() 获取文件的全部信息有个返回数组
|
|
|