[php] inline string vs 兜字串的寫法 速度比較 / 測試 sample code

function timeFunc($function, $runs) { $times = array(); for ($i = 0; $i < $runs; $i++) { $time = microtime(); call_user_func($function); $times[$i] = microtime() – $time; } return array_sum($times) / $runs; } function Method1() { $foo = ‘some words’; for ($i = 0; $i < 10000; $i++) $t = “these are $foo”; } function Method2() { […]