質問編集履歴
7
プログラムコード修正「
test
CHANGED
File without changes
|
test
CHANGED
@@ -68,67 +68,67 @@
|
|
68
68
|
|
69
69
|
<?php
|
70
70
|
|
71
|
-
|
71
|
+
if (isset($_POST["change"])) {
|
72
72
|
|
73
|
-
|
73
|
+
$write = $_POST["change"];
|
74
74
|
|
75
|
-
|
75
|
+
$write_before = $_POST["change_before"];
|
76
76
|
|
77
|
-
|
77
|
+
$write_after = $_POST["change_after"];
|
78
78
|
|
79
79
|
|
80
80
|
|
81
|
-
|
81
|
+
//CRLFを改行1文字にする
|
82
82
|
|
83
|
-
|
83
|
+
$write = str_replace("\r\n", "\n", $write);
|
84
84
|
|
85
85
|
|
86
86
|
|
87
|
-
|
87
|
+
//未入力チェック
|
88
88
|
|
89
|
-
|
89
|
+
if (($write == "")||($write_before == "")||($write_after == "")) {
|
90
90
|
|
91
|
-
|
91
|
+
$result = "入力してください。";
|
92
92
|
|
93
|
-
|
93
|
+
//文入力数チェック
|
94
94
|
|
95
|
-
|
95
|
+
} elseif (mb_strlen($write, 'utf-8') > 100) {
|
96
96
|
|
97
|
-
|
97
|
+
$result = "100文字以内で入力してください。";
|
98
98
|
|
99
|
-
|
99
|
+
//変更後入力数チェック
|
100
100
|
|
101
|
-
|
101
|
+
} elseif (mb_strlen($write_before, 'utf-8') > 100) {
|
102
102
|
|
103
|
-
|
103
|
+
$result = "100文字以内で入力してください。";
|
104
104
|
|
105
|
-
|
105
|
+
//変更後入力数チェック
|
106
106
|
|
107
|
-
|
107
|
+
} elseif (mb_strlen($write_after, 'utf-8') > 100) {
|
108
108
|
|
109
|
-
|
109
|
+
$result = "100文字以内で入力してください。";
|
110
110
|
|
111
|
-
|
111
|
+
} else {
|
112
112
|
|
113
|
-
|
113
|
+
$write_change = htmlspecialchars($write_after, ENT_QUOTES, "UTF-8");
|
114
114
|
|
115
|
-
|
115
|
+
//置換後文字列の色を変える
|
116
116
|
|
117
|
-
|
117
|
+
$write_after = "<span style='color: #ff0000'>$write_change</span>";
|
118
118
|
|
119
|
-
|
119
|
+
//文字列置換
|
120
120
|
|
121
|
-
|
121
|
+
$result = htmlspecialchars(str_replace($write_before, $write_after, $write), ENT_QUOTES, "UTF-8");
|
122
122
|
|
123
|
-
|
123
|
+
$result = str_replace(htmlspecialchars($write_after, ENT_QUOTES, "UTF-8"), $write_after, $result);
|
124
124
|
|
125
|
-
|
125
|
+
}
|
126
126
|
|
127
|
-
|
127
|
+
} else {
|
128
128
|
|
129
|
-
|
129
|
+
$result = "入力していません。";
|
130
130
|
|
131
|
-
|
131
|
+
}
|
132
132
|
|
133
133
|
?>
|
134
134
|
|
@@ -136,41 +136,41 @@
|
|
136
136
|
|
137
137
|
<html>
|
138
138
|
|
139
|
-
|
139
|
+
<head>
|
140
140
|
|
141
|
-
|
141
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
142
142
|
|
143
|
-
|
143
|
+
<title>結果</title>
|
144
144
|
|
145
|
-
|
145
|
+
</head>
|
146
146
|
|
147
|
-
|
147
|
+
<body>
|
148
148
|
|
149
|
-
|
149
|
+
<h2>結果画面</h2>
|
150
150
|
|
151
|
-
|
151
|
+
<table>
|
152
152
|
|
153
|
-
|
153
|
+
<tr>
|
154
154
|
|
155
|
-
|
155
|
+
<td valign="top">結果</td>
|
156
156
|
|
157
|
-
|
157
|
+
<td valign="top">
|
158
158
|
|
159
|
-
|
159
|
+
<?php
|
160
160
|
|
161
|
-
|
161
|
+
echo nl2br($result);
|
162
162
|
|
163
|
-
|
163
|
+
?>
|
164
164
|
|
165
|
-
|
165
|
+
</td>
|
166
166
|
|
167
|
-
|
167
|
+
</tr>
|
168
168
|
|
169
|
-
|
169
|
+
</table>
|
170
170
|
|
171
|
-
|
171
|
+
<a href="chara_input_test02.php">入力画面へ</a>
|
172
172
|
|
173
|
-
|
173
|
+
</body>
|
174
174
|
|
175
175
|
</html>
|
176
176
|
|
6
内容追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -176,7 +176,11 @@
|
|
176
176
|
|
177
177
|
```
|
178
178
|
|
179
|
+
上の二つのPHPで入力フォームに
|
180
|
+
|
179
|
-
|
181
|
+
<span style='color: #ff0000'>tt</span>
|
182
|
+
|
183
|
+
aaaa
|
180
184
|
|
181
185
|
変換前文字列に「aa」変換後文字列に「t」といれると<span>~</span>の文字列が赤文字で「t」だけ出力されます。
|
182
186
|
|
5
プログラムコード記述
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,7 +118,7 @@
|
|
118
118
|
|
119
119
|
//文字列置換
|
120
120
|
|
121
|
-
$result = htmlspecialchars(str_replace($write_before, $write_after, $write
|
121
|
+
$result = htmlspecialchars(str_replace($write_before, $write_after, $write), ENT_QUOTES, "UTF-8");
|
122
122
|
|
123
123
|
$result = str_replace(htmlspecialchars($write_after, ENT_QUOTES, "UTF-8"), $write_after, $result);
|
124
124
|
|
4
文法修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -178,7 +178,7 @@
|
|
178
178
|
|
179
179
|
上の二つのPHPで入力フォームに「<span style='color: #ff0000'>tt</span>,aaaa」
|
180
180
|
|
181
|
-
変換前文字列に「aa」変換後文字列に「t」といれると<span>~</span>の文字列が
|
181
|
+
変換前文字列に「aa」変換後文字列に「t」といれると<span>~</span>の文字列が赤文字で「t」だけ出力されます。
|
182
182
|
|
183
183
|
他の出力は大丈夫でしたがこれだけです。
|
184
184
|
|
3
プログラムコード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,7 +118,7 @@
|
|
118
118
|
|
119
119
|
//文字列置換
|
120
120
|
|
121
|
-
$result = htmlspecialchars(str_replace($write_before,
|
121
|
+
$result = htmlspecialchars(str_replace($write_before, $write_after, $writel), ENT_QUOTES, "UTF-8");
|
122
122
|
|
123
123
|
$result = str_replace(htmlspecialchars($write_after, ENT_QUOTES, "UTF-8"), $write_after, $result);
|
124
124
|
|
2
内容追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,9 +118,9 @@
|
|
118
118
|
|
119
119
|
//文字列置換
|
120
120
|
|
121
|
-
$
|
121
|
+
$result = htmlspecialchars(str_replace($write_before, $write_after, $writel), ENT_QUOTES, "UTF-8");
|
122
122
|
|
123
|
-
$result = str_replace(htmlspecialchars($write_after, ENT_QUOTES, "UTF-8"), $write_after, $
|
123
|
+
$result = str_replace(htmlspecialchars($write_after, ENT_QUOTES, "UTF-8"), $write_after, $result);
|
124
124
|
|
125
125
|
}
|
126
126
|
|
1
文法修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -120,7 +120,7 @@
|
|
120
120
|
|
121
121
|
$write_result = htmlspecialchars(str_replace($write_before, $write_after, $writel), ENT_QUOTES, "UTF-8");
|
122
122
|
|
123
|
-
$
|
123
|
+
$result = str_replace(htmlspecialchars($write_after, ENT_QUOTES, "UTF-8"), $write_after, $write_result);
|
124
124
|
|
125
125
|
}
|
126
126
|
|
@@ -158,8 +158,6 @@
|
|
158
158
|
|
159
159
|
<?php
|
160
160
|
|
161
|
-
$result = htmlspecialchars($result, ENT_QUOTES, "UTF-8");
|
162
|
-
|
163
161
|
echo nl2br($result);
|
164
162
|
|
165
163
|
?>
|