3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string1 = 'aaaaaaaaaaaaaaaaaaaa'; $string2 = 'bbbbbbbbbbbbbbbbbbbb'; $string3 = 'cccccccccccccccccccc'; $string4 = 'dddddddddddddddddddd'; $string5 = 'eeeeeeeeeeeeeeeeeeee'; $time1 = microtime(true); for ($k = 0; $k<10000; $k++) { $concatTest1 = $string1 . $string2 . $string3 . $string4 . $string5; } $time2 = microtime(true); $testDuration1 = $time2 - $time1; echo "Test 1 took $testDuration1 Seconds"; $time3 = microtime(true); for ($m = 0; $m<10000; $m++) { $concatTest2 = "{$string1}{$string2}{$string3}{$string4}{$string5}"; } $time4 = microtime(true); $testDuration2 = $time4 - $time3; echo "Test 2 took $testDuration2 Seconds"; $time5 = microtime(true); for ($p = 0; $p<10000; $p++) { $concatTest3 = implode('', array($string1, $string2, $string3, $string4, $string5)); } $time6 = microtime(true); $testDuration3 = $time6 - $time5; echo "Test 3 took $testDuration3 Seconds";

preferences:
36.16 ms | 402 KiB | 5 Q