[PHP-DEV] Re: PHP 4.0 Bug #7880 Updated: PHP_URL_FOPEN doesn't work From: Alan Halachmi (alan <email protected>)
Date: 11/20/00

php-de> $url = "http://www.php.net/index.html";
php-de> $fp = file($url);
php-de>
php-de>is simply wrong usage, try
php-de>
php-de> $url = "http://www.php.net/index.html";
php-de> $fp = fopen($url,"r");
php-de> $file_contents = file($fp);
php-de>
php-de>instead

Well... First comment is that this worked in v4.0.2

Second comment: I've changed the script to the following:
<?
        $url = "http://www.php.net/index.html";
        $fp = fopen($url,"r");
        $file_contents = file($fp);
        if(!$file_contents) {
                echo "Cannot open url: $url";
        }
        else {
                echo "URL Contents:<BR>\n";
                $size = count($file_contents);
                for($i = 0; $i < $size; $i++) {
                        echo "Line
".($i+1).": ".$file_contents[$i]."<BR>\n";
                }
                echo "End of URL Contents.\n";
        }
?>

and I get the following output:

Warning: fopen("http://www.php.net/index.html","r") - Bad file number in
/home/pkw/devilnet/v1.0/dev/htdocs/filetest.php on line 3

Warning: file("") - No such file or directory in
/home/pkw/devilnet/v1.0/dev/htdocs/filetest.php on line 4
Cannot open url: http://www.php.net/index.html

Look familiar?

TIA!
Alan

--
Alan Halachmi
Wide Area Network Specialist
Ingram Entertainment Network Services
mailto:alan <email protected>
http://www.ingramentertainment.com

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>