Archive - Jan 11, 2007

Date

Amberjack

Amberjack, a 4KB JavaScript site tour creator. Many skins can apply to Amberjack, here shows an Safari skin:
Amberjack
Amberjack works great as a system to improve user's overall experience and knowledge for any website.

Which way to get the PHP self script name is the fastest?

The result shows that __FILE__ is the fastest, so use that when you don't have to use any other method to find the script's self. __FILE__ is a built in constant show the location of the running script. Note that each one of those ways can return different things(like PHP_SELF is different than REQUEST_URI when used some mod_rewrite) but most times those have the same usage, refer to self.
Here is the code for the result:

  $timeparts = explode(' ',microtime());
  $starttime = $timeparts[1].substr($timeparts[0],1);
$i = 1000;
while($i){
	__FILE__;
	--$i;
}
  $timeparts = explode(' ',microtime());
  $endtime = $timeparts[1].substr($timeparts[0],1);
  echo '<br />__FILE__;',bcsub($endtime,$starttime,6);
 
 
 
  $timeparts = explode(' ',microtime());
  $starttime = $timeparts[1].substr($timeparts[0],1);
$i = 1000;
while($i){
	$_SERVER['PHP_SELF'];
	--$i;
}
  $timeparts = explode(' ',microtime());
  $endtime = $timeparts[1].substr($timeparts[0],1);
  echo '<br />','$_SERVER["PHP_SELF"];',bcsub($endtime,$starttime,6);
 
  $timeparts = explode(' ',microtime());
  $starttime = $timeparts[1].substr($timeparts[0],1);
$i = 1000;
while($i){
	$_SERVER['SCRIPT_NAME'];
	--$i;
}
  $timeparts = explode(' ',microtime());
  $endtime = $timeparts[1].substr($timeparts[0],1);
  echo '<br />','$_SERVER["SCRIPT_NAME"];',bcsub($endtime,$starttime,6);
 
  $timeparts = explode(' ',microtime());
  $starttime = $timeparts[1].substr($timeparts[0],1);
$i = 1000;
while($i){
	$_SERVER['REQUEST_URI'];
	--$i;
}
  $timeparts = explode(' ',microtime());
  $endtime = $timeparts[1].substr($timeparts[0],1);
  echo '<br />','$_SERVER["REQUEST_URI"];',bcsub($endtime,$starttime,6);
 
 
  $timeparts = explode(' ',microtime());
  $starttime = $timeparts[1].substr($timeparts[0],1);
$i = 1000;
while($i){
	getenv('REQUEST_URI');
	--$i;
}
  $timeparts = explode(' ',microtime());
  $endtime = $timeparts[1].substr($timeparts[0],1);
  echo '<br />','getenv("REQUEST_URI");',bcsub($endtime,$starttime,6);
 
  $timeparts = explode(' ',microtime());
  $starttime = $timeparts[1].substr($timeparts[0],1);
$i = 1000;
while($i){
	getenv('SCRIPT_NAME');
	--$i;
}
  $timeparts = explode(' ',microtime());
  $endtime = $timeparts[1].substr($timeparts[0],1);
  echo '<br />','getenv("SCRIPT_NAME");',bcsub($endtime,$starttime,6);
 
 
    $timeparts = explode(' ',microtime());
  $starttime = $timeparts[1].substr($timeparts[0],1);
$i = 1000;
while($i){
	getenv('SCRIPT_URL');
	--$i;
}
  $timeparts = explode(' ',microtime());
  $endtime = $timeparts[1].substr($timeparts[0],1);
  echo '<br />','getenv("SCRIPT_URL");',bcsub($endtime,$starttime,6);
Honey Pot that kill bots