Re: [PHP] problem with fread
> erm, don't wanna be nosy, but you meant fgets() - forgot the "s" - > didn't you? Yes I did (early-morning-itis I guess heh). Thanks for the typo correction ;) Ammended code is as follows: >> > $output = ""; // Clear output >> $url = "http://whatever.com/file.html";; // whatever you wanna pull >> from >> >> if ($fp = fopen($url, "r")) { >> while ($tmp = fgets($fp, 4096)) $output .= $tmp; >> fclose($fp); >> } >> >> echo "The URL's content is: ".$output; >> ?> -- Dan Hardiker [[EMAIL PROTECTED]] ADAM Software & Systems Engineer First Creative Ltd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with fread
>$output = ""; // Clear output > $url = "http://whatever.com/file.html";; // whatever you wanna pull from > > if ($fp = fopen($url, "r")) { > while ($tmp = fget($fp, 4096)) $output .= $tmp; > fclose($fp); > } > > echo "The URL's content is: ".$output; > ?> erm, don't wanna be nosy, but you meant fgets() - forgot the "s" - didn't you? just for others who read that one... anyway, so it's safe and clean to use this one. thank you very much! henning -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with fread
> i have a question about the fread() function. > i want to read data from a webserver url, which i don't know the exact > size of, i only know that it varies. You dont actually give the size of the file, you give the size of the block you want to pull. For example: http://whatever.com/file.html";; // whatever you wanna pull from if ($fp = fopen($url, "r")) { while ($tmp = fget($fp, 4096)) $output .= $tmp; fclose($fp); } echo "The URL's content is: ".$output; ?> The "4096" part just means it will pull from the file pointer ($fp) in 4096 byte blocks (or chunks), and the while will keep pulling the chunks until there is nothing left to pull. -- Dan Hardiker [[EMAIL PROTECTED]] ADAM Software & Systems Engineer First Creative Ltd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problem with fread
Hy, i have a question about the fread() function. i want to read data from a webserver url, which i don't know the exact size of, i only know that it varies. i see i have to give the lentgh of a file when reading it, but for remote files i have no way to check the size. And i saw no way to tell fread it should just read until the end. ok, i could set the filesize very high,. but this seems a dirty solution. on the other hand there is the fgets() function to read data "line by line" - but my data has no linbreaks, it's only serialized php variable data that comes in one line. what's the best olution for that situation? tia, henning -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php