留言问题解决 但是想在留言的页面上显示留言内容 思路:读取文件 -- 拆分数组 -- 遍历 --输出数组
但是显示出来的却是这样 原本想输出的是 "水清云影说你怎么这么帅呀!"
代码:
<!DOCTYOE html> <html> <head> <meta charset="UTF-8"> <title>网络留言板模式</title> </head> <body> <?php $filename = 'liuyan.txt'; //判断用户是否按下提交按钮 if(isset($_POST['sub'])){ $message = $_POST['username'] . '||' . $_POST['title'] . '||' . $_POST['mess'] . '&'; write_message($filename,$message); } if(file_exists($filename)){ read_message($filename); } function write_message($filename,$message){ $fp = fopen($filename,"a"); fwrite($fp,$message); fclose($fp); } function read_message($filename){ $mess = file_get_contents($filename); $arrmess = explode('&',$mess); foreach($arrmess as $n){ list($username,$title,$mess) = $arrmess; echo $username.'说 :'; echo ' ' . $title; echo $mess . '<hr>'; } } ?> <form action="1.php" method="POST"> 用户名:<input type = "text" size = '10' name = 'username'><br> 标   题:<input type = "text" size = '30' name = 'title'><br> <textarea name = "mess" rows = "4" cols = "38">请在这里输入留言信息</textarea><br> <input type = "submit" name = 'sub' value = '留言'> </form> </body> </html>
竹夜风影
子期不遇
慕仔5112925