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

回答編集履歴

2

修正

2016/08/09 07:30

投稿

退会済みユーザー
answer CHANGED
@@ -15,6 +15,9 @@
15
15
  public static function debugFile() // <- static に
16
16
  {
17
17
  $file = 'test.txt';
18
+ // 一体どこのファイルを見ているのかを確認
19
+ var_dump(realpath($file));
20
+
18
21
  $current = file_get_contents($file);
19
22
  $current .= "John Smith\n";
20
23
  // 書き込み権限をチェック

1

追記

2016/08/09 07:30

投稿

退会済みユーザー
answer CHANGED
@@ -19,7 +19,7 @@
19
19
  $current .= "John Smith\n";
20
20
  // 書き込み権限をチェック
21
21
  if (!is_writable($file)) {
22
- throw new Exception(sprintf('%s は書き込み権限がありません。'));
22
+ throw new Exception(sprintf('%s は書き込み権限がありません。', $file));
23
23
  }
24
24
  file_put_contents($file, $current);
25
25
  }