[SOLVED] fopen() string size limit?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
McFry
Forum Newbie
Posts: 3
Joined: Fri Jan 07, 2005 12:22 am

[SOLVED] fopen() string size limit?

Post 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

and

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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

well.. you did ask fread to only grab 15000 bytes, if possible.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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?
McFry
Forum Newbie
Posts: 3
Joined: Fri Jan 07, 2005 12:22 am

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
McFry
Forum Newbie
Posts: 3
Joined: Fri Jan 07, 2005 12:22 am

Post by McFry »

Very cool, thanks alot!
Post Reply