Home  >  Article  >  Backend Development  >  php 刷新后 并没有POST 却输出数据解决办法

php 刷新后 并没有POST 却输出数据解决办法

WBOY
WBOYOriginal
2016-06-13 12:31:29802browse

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);
        }
                
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn