PHP Single Quote vs Double Quote
Got an interesting article from my friend fandi.
It goes something like this:
-------------------------------------------------------
function getmicrotime($t) {
list($usec, $sec) = explode(" ",$t);
return ((float)$usec + (float)$sec);
}
$start = microtime();
$a = array();
for($i=0;$i<100;$i++) {
array_push($a, "Aaron rules!");
}
$end = microtime();
$t1 = (getmicrotime($end) - getmicrotime($start));
echo "
?>
Results:
double quotes: 0.001505970954895
single quotes .: 0.00078308582305908
difference........: 0.00072288513183594
------------------------------------------------------------------------
Even a quote makes a difference? Surprised huh? me too!
It goes something like this:
-------------------------------------------------------
function getmicrotime($t) {
list($usec, $sec) = explode(" ",$t);
return ((float)$usec + (float)$sec);
}
$start = microtime();
$a = array();
for($i=0;$i<100;$i++) {
array_push($a, "Aaron rules!");
}
$end = microtime();
$t1 = (getmicrotime($end) - getmicrotime($start));
echo "
double quotes: $t1";
";
unset($a);
$start = microtime();
$b = array();
for($i=0;$i<100;$i++) {
array_push($b, 'Aaron rules!');
}
$end = microtime();
$t2 = (getmicrotime($end) - getmicrotime($start));
$t3 = $t1-$t2;
echo "single quotes: $t2
difference...: $t3
?>
Results:
double quotes: 0.001505970954895
single quotes .: 0.00078308582305908
difference........: 0.00072288513183594
------------------------------------------------------------------------
Even a quote makes a difference? Surprised huh? me too!
0 Comments:
Post a Comment
<< Home