前提・実現したいこと
コメントに通し番号をつけてコメント内容と一緒にテキストファイルに保存したい。
発生している問題・エラーメッセージ
syntax errorが出るのですが原因がわからない。
Parse error: syntax error, unexpected '[' in /home/tt-423.99sv-coco.com/public_html/mission_2-1.php on line 26
該当のソースコード
<html> <body> <form action = "mission_2-1.php" method = "POST"> 名前:<input type ="text" name = "name"><br> コメント:<input type = "text" name = "comment"><input type = "submit" size ="10" value = "送信"> </form> <?php if(isset($_POST["name"])&&isset($_POST["comment"])){ $fp = fopen("mission_2-1.txt","a"); $file = "mission_2-1.txt"; $date = date("Y/m/d H:i:s"); $name = $_POST["name"]; $comment = $_POST["comment"]; $lines = file('mission_2-1.txt'); $lastLine = $lines(count($lines) - 1); $num = explode('<>', $lastLine)[0]; $postdata = $num.$name.$comment.$date."\n"; fwrite($fp,$postdata); fclose($fp); } ?> </body> </html>