Re: PHP 4.0 Bug #7880 Updated: PHP_URL_FOPEN doesn't work
| From: | Alan Halachmi | Date: | Mon, 20 Nov 2000 15:00:48 +0000 |
| Subject: | Re: PHP 4.0 Bug #7880 Updated: PHP_URL_FOPEN doesn't work | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-38614@lists.php.net to get a copy of this message | ||
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@halachmi.net
http://www.ingramentertainment.com