teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

追記

2018/02/21 03:51

投稿

yambejp
yambejp

スコア117944

answer CHANGED
@@ -14,4 +14,19 @@
14
14
  }
15
15
  }
16
16
  ```
17
- ※typo修正
17
+ ※typo修正
18
+ # こまかく検証
19
+ ```PHP
20
+ $path='/storage/logs/articles/';
21
+ $file=$path.$id.'.log';
22
+
23
+ if(!file_exists($path)){
24
+ print "dir not exists";
25
+ }elseif(!is_dir($path)){
26
+ print "not directory";
27
+ }elseif(file_exists($file)){
28
+ print "file exists";
29
+ }else{
30
+ touch($file);
31
+ }
32
+ ```

2

修正

2018/02/21 03:51

投稿

yambejp
yambejp

スコア117944

answer CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  ```PHP
4
4
  $path='/storage/logs/articles/';
5
+ /*
6
+ ご指摘頂いたとおり修正します
5
- $file.=$id.'.log';
7
+ × $file.=$id.'.log';
8
+ */
9
+ $file=$path.$id.'.log';
6
10
 
7
11
  if(file_exists($path) and is_dir($path)){
8
12
  if(!file_exists($file)){

1

修正

2018/02/21 03:32

投稿

yambejp
yambejp

スコア117944

answer CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  ```PHP
4
4
  $path='/storage/logs/articles/';
5
- $file.=$id'.log';
5
+ $file.=$id.'.log';
6
6
 
7
7
  if(file_exists($path) and is_dir($path)){
8
- if(!file_exists($file){
8
+ if(!file_exists($file)){
9
9
  touch($file);
10
10
  }
11
11
  }
12
- ```
12
+ ```
13
+ ※typo修正