Page 1 of 1
[SOLVED] fopen() string size limit?
Posted: Fri Jan 07, 2005 12:25 am
by McFry
Code: Select all
$pageURL="http://127.0.0.01/webdev/php&mysql/counter.php";
$ratepage = fopen("$pageURL","r");
$raw_page = fread($ratepage,15000);
fclose($ratepage);
echo $raw_page;
This script only echos part of the page it was pointed to, as if there is some limit to how much data can be stored.
The counter script that it is pointed to is just a list of bytes-- i was trying to see if there is any logical limit to what it would store (like some whole number of bytes).
Does php, by default, limit the size of the returned string when using fread() or fopen()?
feyd | Help us, help you. Please use Code: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Fri Jan 07, 2005 12:28 am
by feyd
well.. you did ask fread to only grab 15000 bytes, if possible.
Posted: Fri Jan 07, 2005 12:29 am
by markl999
It shouldn't limit it at least not for what you're using it for, only you are setting a limit of 15000 bytes.
Have you tried using :
Code: Select all
$raw_page = file_get_contents('http://127.0.0.01/webdev/php&mysql/counter.php');
echo $raw_page;
.. instead?
Posted: Fri Jan 07, 2005 12:37 am
by McFry
i didn't know about file_get_contents(), but that appears to work. What's the difference in how this function and fopen() works though?
Thanks!
Posted: Fri Jan 07, 2005 12:39 am
by feyd
[php_man]file_get_contents()[/php_man] does a [php_man]fopen()[/php_man] and total [php_man]fread()[/php_man] loop until the entire file is read, or your memory is exhausted.
Posted: Fri Jan 07, 2005 12:48 am
by McFry
Very cool, thanks alot!