Edit report at https://bugs.php.net/bug.php?id=61336&edit=1
ID: 61336 Comment by: vestigalorgan at gmail dot com Reported by: ram...@php.net Summary: file_get_contents() no longer returns false on 4xx responses Status: Open Type: Bug Package: Filesystem function related Operating System: CentOS 6.2 PHP Version: 5.4.0 Block user comment: N Private report: N New Comment: I'm experiencing a similar issue in the PHP version 5.4.7 that ships with XAMPP. When I open a web URL that throws a warning such as "Warning: file_get_contents(http://[ip_address_here]:[port_here]): failed to open stream: No connection could be made because the target machine actively refused it.", file_get_contents() returns an empty string, instead of false. I'm not sure if this is related to this bug or I should file a new one. I'm experiencing this on Windows 7 Professional, SP1 32-bit. I'm only using the first parameter of file_get_contents(). Previous Comments: ------------------------------------------------------------------------ [2012-10-18 15:51:46] stasismedia at gmail dot com I should add... Both PHP versions in Ubuntu 12.04 x64 running as a guest in Virtualbox. ------------------------------------------------------------------------ [2012-10-18 15:43:27] stasismedia at gmail dot com I actually get the same issue on both 5.3.11 and 5.4.4: 5.3.11: ------- array(11) { [0]=> string(22) "HTTP/1.1 404 Not Found" [1]=> string(35) "Date: Thu, 18 Oct 2012 15:35:04 GMT" [2]=> string(29) "Server: Apache/2.2.3 (CentOS)" [3]=> string(23) "X-Powered-By: PHP/5.3.2" [4]=> string(20) "Content-language: en" [5]=> string(88) "Set-Cookie: LAST_LANG=en; expires=Fri, 18-Oct-2013 15:35:04 GMT; path=/; domain=.php.net" [6]=> string(101) "Set-Cookie: COUNTRY=GBR%2C94.195.8.27; expires=Thu, 25-Oct-2012 15:35:04 GMT; path=/; domain=.php.net" [7]=> string(21) "Status: 404 Not Found" [8]=> string(20) "Content-Length: 4182" [9]=> string(17) "Connection: close" [10]=> string(37) "Content-Type: text/html;charset=utf-8" } string(4182) "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 5.4.4: ------- array(11) { [0] => string(22) "HTTP/1.1 404 Not Found" [1] => string(35) "Date: Thu, 18 Oct 2012 15:35:19 GMT" [2] => string(29) "Server: Apache/2.2.3 (CentOS)" [3] => string(23) "X-Powered-By: PHP/5.3.2" [4] => string(20) "Content-language: en" [5] => string(88) "Set-Cookie: LAST_LANG=en; expires=Fri, 18-Oct-2013 15:35:19 GMT; path=/; domain=.php.net" [6] => string(101) "Set-Cookie: COUNTRY=GBR%2C94.195.8.27; expires=Thu, 25-Oct-2012 15:35:19 GMT; path=/; domain=.php.net" [7] => string(21) "Status: 404 Not Found" [8] => string(20) "Content-Length: 4182" [9] => string(17) "Connection: close" [10] => string(37) "Content-Type: text/html;charset=utf-8" } string(4182) "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n ------------------------------------------------------------------------ [2012-03-30 16:39:42] ras...@php.net Unable to reproduce this on any of my Ubuntu 11.10 or Centos machines. I have Centos in a VM, but not Virtualbox. Perhaps you have some weird proxying going on? Break out tcpdump and see what is actually coming across the wire. ------------------------------------------------------------------------ [2012-03-30 06:29:59] ram...@php.net I've just done a clean install of Ubuntu 11.10 on VirtualBox and then built PHP 5.4 from the PHP-5.4 branch. I am still encountering this problem. As this point, the single commonality between environments is that I'm using VirtualBox. Could this problem be a result of the way in which VirtualBox accesses the network? ------------------------------------------------------------------------ [2012-03-29 23:19:19] ram...@php.net I've just checked out the PHP-5.3 branch on the same environments and built it with exactly the same config values as my 5.4 builds. `php --version` shows me this: PHP 5.3.11-dev (cli) (built: Mar 29 2012 19:12:58) It appears that I'm having the exact same problem with the latest checkout from PHP 5.3 in these same two environments (Debian 6.0.4 and CentOS 6.2). Either I have a problem in both of these environments, or the code that is broken in 5.4 has recently been merged to 5.3. Unfortunately, others that I have asked to test this cannot reproduce it in their environments, so that points to a problem with my environment. Any help identifying that problem is greatly appreciated. I have posted detailed instructions on exactly what I have done to set up each environment. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=61336 -- Edit this bug report at https://bugs.php.net/bug.php?id=61336&edit=1