header(
"Content-type:text/html;charset=utf-8"
);
$url
=
'./b.txt'
;
//读取小文件是使用 切记使用双引号
$conf
=
file_get_contents
(
$url
);
$arr
=
explode
(
"\n"
,
$conf
);
$arr
= file(
$url
);
//读取小文件是使用
$hr
=
fopen
(
$url
,
'r'
);
//大文件使用每行读取
while
(!
feof
(
$hr
)){
$arr
[]=
fgets
(
$hr
);
}
echo
'<pre>'
;
print_r(
$arr
);
$ch
= curl_init();
curl_setopt(
$ch
, CURLOPT_URL,
"http://bbs.php100.com/read-htm-tid-479429.html"
);
curl_setopt(
$ch
, CURLOPT_ENCODING,
""
);
curl_setopt(
$ch
, CURLOPT_HEADER, false);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //如果把这行注释掉的话,就会直接输出
$result
=curl_exec(
$ch
);
curl_close(
$ch
);
//查找文件夹下的文件判断大小和禁止文字
$u
=
'fuck'
;
foreach
(
glob
(
'wenjian/*.php'
)
as
$v
) {
if
(
filesize
(
$v
)<10){
unlink(
$v
);
echo
$v
.
'文件小于10字节<br>'
;
continue
;
}
$conf
=
file_get_contents
(
$v
);
if
(
stripos
(
$conf
,
$u
) !==false){
unlink(
$v
);
echo
$v
.
'文件有不文明用语<br>'
;
continue
;
}
echo
str_replace
(
'wenjian/'
,
''
,
$v
).
'文件安全<br>'
;
}
//目录操作判断目下文件与文件夹
$path
=
'./wenjian/'
;
$fh
= opendir(
$path
);
while
( (
$filename
= readdir(
$fh
)) !== false ){
echo
$filename
;
if
(
is_dir
(
$path
.
$filename
)){
echo
'是文件夹'
;
}
echo
'<br>'
;
}
//创建文件夹
$arr
= [
'a'
,
'b'
,
'c'
,
'd'
];
mkdir
(
$arr
,0777,true);
foreach
(
$arr
as
$v
) {
$path
=
'./wenjian/'
.
$v
;
if
(
file_exists
(
$path
)&&
is_dir
(
$path
)){
echo
$path
.
'已存在<br>'
;
continue
;
}
if
(
mkdir
(
$path
)){
echo
$path
.
'创建成功<br>'
;
}
}
//删除文件夹
$arr
=[
'a'
,
'b'
,
'c'
];
foreach
(
$arr
as
$v
){
$path
=
'./wenjian/'
.
$v
;
if
(
file_exists
(
$path
) &&
is_dir
(
$path
)){
if
(
rmdir
(
$path
)){
echo
$path
.
'删除成功<br>'
;
}
else
{
echo
$path
.
'删除失败<br>'
;
}
}
else
{
echo
$path
.
'目录不存在<br>'
;
}
}