Page 1 of 1

Why does feof hate me??

Posted: Wed Jun 04, 2003 11:35 am
by ChineseStunna
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

Posted: Wed Jun 04, 2003 12:42 pm
by twigletmac
The error message:
Parse error: parse error, unexpected T_VARIABLE in /home/zeuspc/public_html/news/mailp.php on line 5
indicates that there is something wrong above line 5 - what's on lines 1-4?

Mac

Posted: Wed Jun 04, 2003 12:54 pm
by ChineseStunna
Err... LOL thanks, sorry left out a ; on 4 :P

Thank you very much