php 刷新后 并没有POST 却输出数据解决办法
程序员文章站
2022-05-26 09:44:36
...
php 刷新后 并没有POST 却输出数据
我的php代码如下:
网络留言板
//error_reporting(E_ALL & ~E_NOTICE);
function write_message($file_name, $message)
{
$fp = fopen($file_name, "a"); //以追加模式打开文件
if(flock($fp, LOCK_EX))
{
fwrite($fp, $message);
flock($fp, LOCK_UN);
}
else
{
echo "不能锁定文件
";
}
fclose($fp); //关闭文件资源
}
//自定义一个遍历读取文件的函数
function read_message($file_name)
{
$fp = fopen($file_name, "r"); //以只读模式打开文件
flock($fp, LOCK_SH);
$buffer = "";
while(!feof($fp))
{
$buffer .= fread($fp, 1024);
}
$data = explode("", $buffer);
unset($data[count($data)-1]);
foreach($data as $line)
{
$arr = explode("||", $line);
list($user_name, $title, $message) = $arr;
if($user_name != "" && $title != "" && $message != "")
{
echo $user_name.'说 ';
echo " ".$title.' ';
echo $message."
";
}
}
flock($fp, LOCK_UN);
fclose($fp);
}
我的php代码如下:
//error_reporting(E_ALL & ~E_NOTICE);
function write_message($file_name, $message)
{
$fp = fopen($file_name, "a"); //以追加模式打开文件
if(flock($fp, LOCK_EX))
{
fwrite($fp, $message);
flock($fp, LOCK_UN);
}
else
{
echo "不能锁定文件
";
}
fclose($fp); //关闭文件资源
}
//自定义一个遍历读取文件的函数
function read_message($file_name)
{
$fp = fopen($file_name, "r"); //以只读模式打开文件
flock($fp, LOCK_SH);
$buffer = "";
while(!feof($fp))
{
$buffer .= fread($fp, 1024);
}
$data = explode("", $buffer);
unset($data[count($data)-1]);
foreach($data as $line)
{
$arr = explode("||", $line);
list($user_name, $title, $message) = $arr;
if($user_name != "" && $title != "" && $message != "")
{
echo $user_name.'说 ';
echo " ".$title.' ';
echo $message."
";
}
}
flock($fp, LOCK_UN);
fclose($fp);
}
相关文章
相关视频