| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2003-03-27 18:41 UTC] freddie at bingham dot net
 Consider the following script:
<?php
$p = fopen('http://pub133.ezboard.com/bonesixthwarriors', 'rb');
$p2 = fopen('http://www.microsoft.com', 'rb');
?>
Both sites are opened when using php 4.2.3 (and earier version) whereas 4.3.1 throws the following warning:
Warning: fopen(http://pub133.ezboard.com/bonesixthwarriors) [function.fopen]: failed to create stream: HTTP request failed! in /home/juan/public_html/forums/foo.php on line 3
Considering that the second fopen() generates no warnings, fopen is working in some cases in regards to urls. Of course, Apache has been restarted numerous times with no effect.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 01:00:02 2025 UTC | 
In my problem case, the remote file does NOT exist. This is what I want to find out with fopen(). The according code looks like this: // don't check remote files with file_exists() !!! if ($lan == "cz") { $file = fopen("$url_docu", "rb"); if ($file) { echo "<blockquote>\n"; echo "<a href=\"$url_docu\" class=\"h4\">"; $this->echo_name($lan); echo " (HTML)</a>\n"; echo "</blockquote>\n"; fclose($file); } else [...] } In fact, $file is invalid here as it should. But in no case this function call of fopen() should give a warning about this, shouldn't it? In http://www.calamus.net/cz/modules/aln.php, you see how it works with existing remote files. In http://www.calamus.net/us/modules/aln.php, you can see how the result should be (refer to 'Manual' instead of the Czech 'Prirucka').dunkel at calamus dot net: fopen will raise a warning if it could not open the file. That is how it works. To hide the warning, use the @ operator. freddie at bingham dot net: please try this little script: $p = fopen('http://pub133.ezboard.com/bonesixthwarriors', 'rb'); var_dump($http_response_headers); and paste the result here*sigh* Please provide the information I requested. <?php $p = fopen('http://pub133.ezboard.com/bonesixthwarriors', 'rb'); var_dump($http_response_headers); ?> and paste the result here.I'm afraid I can verify this one, both with 4.3.2 and 4.3.3-dev as of today: # sapi/cli/php -c php.ini-recommended -r ' $p = fopen("http://pub133.ezboard.com/bonesixthwarriors", "rb"); var_dump($http_response_headers); ' PHP Warning: fopen(http://pub133.ezboard.com/bonesixthwarriors): failed to open stream: HTTP request failed! ?|?c ???????? in Command line code on line 2 PHP Notice: Undefined variable: http_response_headers in Command line code on line 3 NULL # Configured only with --enable-debug --disable-mbstring, it's the same problem, but slightly different junk characters in the error message. Otherwise these junk characters are always the same (for the same build).Try the following test: <?php ini_set('user_agent', 'PHP/4.3.2'); $p = fopen('http://pub133.ezboard.com/bonesixthwarriors', 'rb'); $p2 = fopen('http://www.microsoft.com', 'rb'); ?>