does readfile() take lots of resources?

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
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

does readfile() take lots of resources?

Post by hongco »

Hi,

Many users here mention about using readfile() in order to protect their files from leeching? Would readfile take more resources (bandwidth)? example, if i wanted to play a song with mp3 format, which one will result in more bandwidth use: using the Embed tag or readfile()?

Thanks! :D
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: does readfile() take lots of resources?

Post by infolock »

hongco wrote:Hi,

Many users here mention about using readfile() in order to protect their files from leeching? Would readfile take more resources (bandwidth)? example, if i wanted to play a song with mp3 format, which one will result in more bandwidth use: using the Embed tag or readfile()?

Thanks! :D
as far as bandwidth goes, you aren't actually going to see a difference.. as far as resources goes, it's according to how big the file is and how big memory_limit is set to as it will only allow file sizes that match the maximum value of memory_limit.
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

Thanks infolock!

The readfile function takes the whole file into memory at once.

How does the html embed tag works when embedding mp3 file? does it load the file onto the client as temp file? if this is true, would this help reduce resource on the server which hosts the mp3 file?

Thanks again!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the server must still transfer the file no matter what.. so it wouldn't really affect anything I'm aware of.
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

thanks feyd
Post Reply