質問編集履歴
1
質問を入力せずに先ほど間違えて投稿しました。失礼しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
### phpで掲示板を作成勉強中です。教本にはboard.txtにテキストファイルにメッセージを保存とありますが、変数に代入しただけでテキストファイルが作成されているのでしょうか。
|
2
|
+
|
3
|
+
```ここに言語を入力
|
4
|
+
|
1
5
|
<!DOCTYPE html>
|
2
6
|
|
3
7
|
<html lang="en">
|
@@ -62,4 +66,38 @@
|
|
62
66
|
|
63
67
|
|
64
68
|
|
65
|
-
?>
|
69
|
+
?>
|
70
|
+
|
71
|
+
<?php
|
72
|
+
|
73
|
+
$file = 'board.txt';
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
if(file_exists($file)){
|
78
|
+
|
79
|
+
$board = json_decode(file_get_contents($file));
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
$board[]=$_REQUEST['message'];
|
84
|
+
|
85
|
+
file_put_contents($file, json_encode($board));
|
86
|
+
|
87
|
+
foreach($board as $message){
|
88
|
+
|
89
|
+
echo '<p>' ,$message, '</p><hr>';
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
?>
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
コード
|
102
|
+
|
103
|
+
```
|