yuckysocks Posted January 22, 2009 Share Posted January 22, 2009 Hi there. Running examples from a webbots book. Here's the code: <? $target = "http://www.schrenk.com/nostarch/webbots/hello_world.html"; $file_handle = fopen($target, "r"); #fetch the file while (!feof(file_handle)) echo fgets($file_handle, 4096); fclose($file_handle); ?> I ran it from terminal on OS X 10.5 (FWIW) and it spat back infinite lines of: Warning: feof(): supplied argument is not a valid stream resource Instead of the expected line-by-line response from the targeted web server. It DOES show the source HTML after each error message, but when the source is done, the errors continue to infinity and I have to close Terminal. I'm a PHP newbie, so go ahead and talk down to me Thanks for explaining what's happening, Alex Link to comment https://forums.phpfreaks.com/topic/141889-solved-feof-error/ Share on other sites More sharing options...
haku Posted January 22, 2009 Share Posted January 22, 2009 Look at this again: while (!feof(file_handle)) you're missing something. Link to comment https://forums.phpfreaks.com/topic/141889-solved-feof-error/#findComment-742939 Share on other sites More sharing options...
yuckysocks Posted January 22, 2009 Author Share Posted January 22, 2009 hrmm. at -least a semi colon. (isn't it always a semi-colon?) but that still dumped out the errors. I don't know much about the functions (it's a hello world example, after all) file_handle looks like a variable, so I tried it with a $ in front: while (!feof($file_handle)); but that didn't reply with -anything- still stumped! Link to comment https://forums.phpfreaks.com/topic/141889-solved-feof-error/#findComment-742941 Share on other sites More sharing options...
haku Posted January 22, 2009 Share Posted January 22, 2009 Your error was that you were missing the $. If you aren't getting anything, that is a separate problem with your code, and you should start a new thread, as this error has been solved. Also, you should use <?php instead of <?. The short tag that you are using is sloppy programming as it may stop working suddenly if your host changes their server settings. Or if you move it to a new server, it may not work if they have short tags turned off. Link to comment https://forums.phpfreaks.com/topic/141889-solved-feof-error/#findComment-742943 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.