file_exists()检查文件是否存在
<?php
if(file_exists("file.txt"))
{
echo '执行';
}
else {
echo '文件不存在';
}
?>
filesize()文件大小
<?php
echo filesize('file.txt');
?>
以字节为单位
删除文件unlink()
<?php
unlink('file.txt');
?>
rewind()倒回文件指针位置
<?php
$fp=fopen('file.txt','r');
echo fgetc($fp);
?>
此时指针在第二个字母在输入fgetc依次往后
直接在代码后加
rewind($fp);
fseek()在文件指针中定位
<?php
$b=fopen('file.txt','r');
fseek($b,2);
echo fgetc($b);
?>
文件锁定flock()
<?php
$b=fopen('file.txt','ab');
flock($b,LOCK_EX);
fwrite($b,'this islock');
flock($b,LOCK_UN);
?>