Reply to Re: [PHP] turn off the www

Your name:

Reply:


Posted by Andrι Medeiros on 06/29/05 23:56

People have fun with the oddest things ;)

Anyway, it's a nice reference to have around :)

On 6/29/05, Philip Hallstrom <php@philip.pjkh.com> wrote:
> > OK OK I got it ;)
> >
> > I just suggested it because I thought he could assume that "www."
> > would always be on the string.
> >
> > Either way, I guess _one_ preg_replace is alright.
>
> Heh :-) Just for kicks...
>
> - randomly prefix "www." onto 1324 proper names (dictionary file). 659 end
> up with "www." prefixed.
>
> - wrote a script to load them all up into an array, then loop through
> doing an ereg, substr, and preg. Each block looks like this:
>
> reset($ary);
> $stime = microtime(true);
> foreach ( $ary as $w ) {
> $w = ereg_replace("^www\.", "", $w);
> }
> $etime = microtime(true);
> $ttime = $etime - $stime;
> print("ereg_replace: $ttime\n");
>
> The only differenec being the line in the foreach loop.
>
> Ran it several times on a fairly quite box and always got pretty similar
> results...
>
> ereg_replace: 0.0057849884033203
> substr: 0.0025739669799805
> preg_replace: 0.004335880279541
>
> Anyway... there's some stats for the archive :-)
>
> >
> > On 6/29/05, Kevin L'Huillier <klhuillier@gmail.com> wrote:
> >>>> Wouldn't
> >>>>
> >>>> $newUrl = 'https://' . substr( $_SERVER['SERVER_NAME'], 4 ) .........
> >>>>
> >>>> be a _hell_ of a lot faster?
> >>>
> >>> If one considers micro-seconds 'a _hell_ of a lot faster', then _maybe_
> >>
> >> And it could be slower if you avoid sending someone from
> >> http://example.com/ to https://ple.com/ by adding a substring
> >> check.
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация