header("Content-type:text/htmlcharset=utf-8")
$f_open = fopen('aaa.txt','w+') //打开文件
if(isset($_POST['submit'])){//判断,如果点了提交按钮则执行以下代码
fwrite($f_open,$_POST['txt']) //写入文件,内容为文本域传过来的值
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
textarea{
width: 300px
height: 20px
}
</style>
</head>
<body>
<form method="post" action="a.php">
<textarea name="txt">
<?php
$aaa = readfile('aaa.txt') //读取aaa.txt的内容
?>
</textarea>
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
fclose($f_open) //关闭文件
?>
<?php$handle = @fopen("1.txt", "r")
$str=""
if ($handle) {
for($i=0$i++$i<3){
$buffer = fgets($handle, 4096)
if(strpos($buffer,"aaaa")!==false){
$str.= $buffer
}elseif(strpos($buffer,"bbbb")!==false){
$str.= "[".$buffer."]"
}elseif(strpos($buffer,"cccc")!==false){
$str.= "(".$buffer.")"
}
}
fclose($handle)
}
echo $str
?>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)