Re: turn off the www

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> 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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux