Why does feof hate me??
Posted: Wed Jun 04, 2003 11:35 am
so I'm just trying to learn how to do some txt file parsing with php and here's what I've tried so far:
$handle = fopen("test.txt", "r+");
fwrite($handle,"This works", 1024);
fclose($handle);
and test.txt will have This works written into it.
but, since I need to parse and existing file, I have to read it into a buffer first:
$handle = fopen("mail.txt", "r");
while (!feof($handle))
{
$buffer = fread($handle, 4096);
}
this would cause a parse error in the $handle = fopen(...) line?! What the hell? I've been reading php.net's page on feof and fopen forever now and I can't figure out why that just won't wory and would tell me this:
Parse error: parse error, unexpected T_VARIABLE in /home/zeuspc/public_html/news/mailp.php on line 5
line5 being the $handle = fopen(...) line.
Thanks in advance
Stunna
$handle = fopen("test.txt", "r+");
fwrite($handle,"This works", 1024);
fclose($handle);
and test.txt will have This works written into it.
but, since I need to parse and existing file, I have to read it into a buffer first:
$handle = fopen("mail.txt", "r");
while (!feof($handle))
{
$buffer = fread($handle, 4096);
}
this would cause a parse error in the $handle = fopen(...) line?! What the hell? I've been reading php.net's page on feof and fopen forever now and I can't figure out why that just won't wory and would tell me this:
Parse error: parse error, unexpected T_VARIABLE in /home/zeuspc/public_html/news/mailp.php on line 5
line5 being the $handle = fopen(...) line.
Thanks in advance
Stunna