I have some code which is working on one server, but only under cirtain circustances on another. The servers are running different versions of PHP. I suspect that's the problem. But am not sure. Please help me figure this one out.
The problem is with the file() function.
On the server running PHP 4.2.1, this code works fine:
$lines = file('http://www.metafilter.com/mefi/24855');
While($line = next($lines)) { echo $line . "\n"; }
On the server running PHP 4.3.1, I get the following error:
Warning: file(http://www.metafilter.com/mefi/24855) [function.file]: failed to create stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
However (and here's the wierd part), on BOTH servers the following code works fine:
$lines = file('http://www.metafilter.com');
While($line = next($lines)) { echo $line . "\n"; }
So I know that file() is working on the 4.3.1 server. But it doesn't seem to work if I have anything after the domain name other than a slash. And it does seem related to this site. Requests to other sites don't seem to display the same problem.
If it was something the site (metafilter.com) was doing I would expect it to fail on both 4.2.1 and 4.3.1.
Any ideas?