回答編集履歴
3
追記
answer
CHANGED
@@ -26,4 +26,16 @@
|
|
26
26
|
throw new Exception('ファイルの削除に失敗しました');
|
27
27
|
}
|
28
28
|
}
|
29
|
+
```
|
30
|
+
|
31
|
+
```php
|
32
|
+
<?php
|
33
|
+
|
34
|
+
foreach (['photo.jpg', 'thumb.jpg'] as $file) {
|
35
|
+
if (file_exists($file)) {
|
36
|
+
if (!unlink($file)) {
|
37
|
+
throw new Exception('ファイルの削除に失敗しました');
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
29
41
|
```
|
2
修正
answer
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
---
|
13
13
|
|
14
|
-
実装として正しいのはこっちだろうな
|
14
|
+
実装として正しいのはこっちだろうな
|
15
15
|
|
16
16
|
```php
|
17
17
|
<?php
|
1
追記
answer
CHANGED
@@ -7,4 +7,23 @@
|
|
7
7
|
throw new Exception('ファイルの削除に失敗しました');
|
8
8
|
}
|
9
9
|
|
10
|
+
```
|
11
|
+
|
12
|
+
---
|
13
|
+
|
14
|
+
実装として正しいのはこっちだろうな」
|
15
|
+
|
16
|
+
```php
|
17
|
+
<?php
|
18
|
+
|
19
|
+
if (file_exists('photo.jpg')) {
|
20
|
+
if (!unlink('photo.jpg')) {
|
21
|
+
throw new Exception('ファイルの削除に失敗しました');
|
22
|
+
}
|
23
|
+
}
|
24
|
+
if (file_exists('thumb.jpg')) {
|
25
|
+
if (!unlink('thumb.jpg')) {
|
26
|
+
throw new Exception('ファイルの削除に失敗しました');
|
27
|
+
}
|
28
|
+
}
|
10
29
|
```
|