[pLog-svn] r4693 - plog/branches/lifetype-1.2/class/net/http/session

Jon Daley plogworld at jon.limedaley.com
Mon Feb 5 19:37:14 EST 2007


 	I haven't done any tests with it - how much memory/resources does 
it use?  If it is significant, maybe we should just use str_replace. 
Oscar - does the string you are searching have a http:// prefix?  If so, 
we could use str_replace, but search for "http://www." instead of just 
"www."

On Mon, 5 Feb 2007, Matt Wood wrote:
> ugh. I'm an iddiot. Reading top down or something.
>
> On 2/5/07, Matt Wood <matt at woodzy.com> wrote:
>> 
>> preg_replace take significantly more time (and memory) to execute than
>> str_replace... just wondering what your rationale for this was...
>> 
>> From PHP Website:
>> mixed *str_replace* ( mixed search, mixed replace, mixed subject [, int
>> &count] )
>> This function returns a string or an array with all occurrences of *search
>> * in *subject* replaced with the given *replace* value. If you don't need
>> fancy replacing rules (like regular expressions), you should always use 
>> this
>> function instead of 
>> ereg_replace()<http://hu.php.net/manual/en/function.ereg-replace.php>or
>> preg_replace() <http://hu.php.net/manual/en/function.preg-replace.php>.
>> 
>> On 2/5/07, oscar at devel.lifetype.net <oscar at devel.lifetype.net> wrote:
>> >
>> > Author: oscar
>> > Date: 2007-02-05 17:15:16 -0500 (Mon, 05 Feb 2007)
>> > New Revision: 4693
>> >
>> > Modified:
>> >    plog/branches/lifetype-1.2
>> > /class/net/http/session/sessionmanager.class.php
>> > Log:
>> > Added Jon's fix
>> >
>> >
>> > Modified: plog/branches/lifetype-1.2
>> > /class/net/http/session/sessionmanager.class.php
>> > ===================================================================
>> > --- 
>> plog/branches/lifetype-1.2/class/net/http/session/sessionmanager.class.php 
>> 2007-02-05
>> > 21:49:03 UTC (rev 4692)
>> > +++ 
>> plog/branches/lifetype-1.2/class/net/http/session/sessionmanager.class.php 
>> 2007-02-05
>> > 22:15:16 UTC (rev 4693)
>> > @@ -104,7 +104,7 @@
>> >                                 $scriptUrl = HttpVars::getBaseUrl();
>> >
>> >                         $url = new Url( $scriptUrl );
>> > -                       $domain = str_replace( "www.", ".",
>> > $url->getHost());
>> > +                       $domain = preg_replace("/^www\./", ".",
>> > $url->getHost());
>> >
>> >                         // this won't work for top level domains and
>> > domains such as
>> >                         // 'localhost' or internal domains for obvious
>> > security reasons...
>> >
>> > _______________________________________________
>> > pLog-svn mailing list
>> > pLog-svn at devel.lifetype.net
>> > http://limedaley.com/mailman/listinfo/plog-svn
>> >
>> 
>> 
>

-- 
Jon Daley
http://jon.limedaley.com/

I have never met a man so ignorant that
I couldn't learn something from him.
-- Galileo Galilei


More information about the pLog-svn mailing list