都是换行惹的祸

PHP filesize 操作得到 Warning: filesize() [function.filesize]: stat failed for…

在使用以下 PHP 代码时遇到了些问题。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# list.txt
/*
    Be More.mp3
    Hello.mp3
    Drift Away.mp3
    Panda Sneeze.mp3
*/

$lines = file("list.txt");
foreach ($lines as $line){
    echo filesize($line);
    // code above get results like following except the last line:
    // Warning: filesize() [function.filesize]: stat failed for songs/Hello.mp3 in ...
    # echo filesize("songs/Hello.mp3");  // this'll be ok
}

继续阅读“都是换行惹的祸”