XML parsing

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
hexahedron
Forum Newbie
Posts: 1
Joined: Fri Jan 24, 2003 12:16 pm

XML parsing

Post by hexahedron »

I've been doing some xml parsing, using the example script from php.net:
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
I noticed that all the fread() functions shown in the examples gave 4096 as the argument for the number of bytes to read. I also noticed that, for the fread function, the examples given suggested:
$contents = fread ($handle, filesize ($filename));
Is there a good reason why I shouldn't use the whole filesize for parsing xml?

--Joel
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

they are just examples ;)
But note
The results of this function are cached. See clearstatcache() for more details.
at the manual page of filesize()
Post Reply