Re: Implode slows down file reading? [was: str_replace performance in large mailing script]

From: Date: Wed, 27 Aug 2003 21:13:18 +0000
Subject: Re: Implode slows down file reading? [was: str_replace performance in large mailing script]
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-160964@lists.php.net to get a copy of this message
* Thus wrote CPT John W. Holmes (holmes072000@charter.net): > From: "frederik feys" <frederikfeys@pandora.be> > > > I thought str_replace caused slow down of my mailing script, but it > > seems to be this line of code: > > > > $fd = > > > > implode("",file("http://www.domain.org/store/min/Mailing_template.html") > > ); > > > > I first put the mailing template in $fd (only once) and then replace > > (str_replace) elements of it to individualize HTML emails. > > Btw i'm using php version 4.0.6. > > > > Are there better(faster) ways to read the contents of a file? > > file_get_contents() ? unfortantly this is only (PHP 4 >= 4.3.0). imploading a file all the time from file simply doesn't make sense to me, i would fread() the file directly into a string instead. > > The slow down is probably because you're going through HTTP to read the > file. Is there a reason for that? Any way you can cache the file locally so > it's not read through HTTP all of the time? Yep, reading through http is the slowdown. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#160964) next »