Reply to Re: [PHP] turn off the www

Your name:

Reply:


Posted by Philip Hallstrom on 06/29/05 23:16

> 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

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация