How do I read all the characters?

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
joetheeskimo5
Forum Commoner
Posts: 43
Joined: Sun Dec 14, 2003 4:47 pm
Location: US
Contact:

How do I read all the characters?

Post by joetheeskimo5 »

How can I read all the bytes in a document with fread() instead of entering a certain number?

Thanks,
Joe
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

$contents = fread($handle, filesize($filename));
Is this what you're looking for?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Or file_get_contents or file if you want each line as an array element.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

Code: Select all

<?php

$fp = fopen($filename, "r");
$filecontents = fread($fp, filesize($filename));

?>
Post Reply