<?php
if (isset($_GET['source'])) {
  
highlight_file(__FILE__);
  exit;
}

header('Content-Type: text/plain');

$foo 23;
$bar 42;
$doh "d'oh!";
$result = array();

print 
"string building with three embedded variables\n";
print 
"three tests: concatenation, embedding, sprintf()\n";
print 
"300,000(!) invokations each\n\n";

$starTime microtime(TRUE);
for (
$i 0$i 300000$i++) {
  
$test 'some text '.$foo.' with some '.$bar.' embedded '.$doh.' variables';
}
$endTime microtime(TRUE);
$result['concat: '] = $endTime-$starTime;

$starTime microtime(TRUE);
for (
$i 0$i 300000$i++) {
  
$test "some text $foo with some $bar embedded $doh variables";
}
$endTime microtime(TRUE);
$result['embed:  '] = $endTime-$starTime;

$starTime microtime(TRUE);
for (
$i 0$i 300000$i++) {
  
$test sprintf('some text %u with some %u embedded %s variables'$foo$bar$doh);
}
$endTime microtime(TRUE);
$result['sprintf:'] = $endTime-$starTime;

print 
'Result (times in s): ';
print_r($result);
?>