View Single Post
Old 06-23-2009, 03:06 AM   #1 (permalink)
benton
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default Simple script fails with php5

I have a script that reads the file contents of a site. My host recently upgraded to php 5 and the script doesn't work correctly. It still runs without errors but takes much longer and no results are found. I've narrowed down the code to this
Code:
$file = @fopen($filename, "r");
if (!$file) 
{
  echo "<p>Unable to open remote file $filename.\n";
}
else
{          
  while (!feof($file)) 
  {
  }
}
If I remove the while (!feof($file)) line, the script executes quickly. If I leave it in, it takes almost a minute before it returns. I checked the php manual to see if there is a difference betwen these functions for php 4 and 5 but didn't find anything. Does anyone have any ideas as to why this fails when php 5 is enabled or any suggestions on another method?
benton is offline  
Reply With Quote