--- anders thoresson <[EMAIL PROTECTED]> wrote: > Which is more efficient:
Your first method is more efficient according to my quick test, though I find myself preferring the second when I write code due to the readability advantages. The difference is small, however. Here is the code I used to test, so you can try it out (and verify my method of testing) for yourself: <? $foo = 'bar'; # TIME FIRST METHOD list($microseconds, $seconds) = explode(' ', microtime()); $start_time = floatval($seconds) + floatval($microseconds); for ($i = 0; $i < 100; $i++) { echo "a href=\"" . $_SERVER['PHP_SELF'] . "?action=" . $foo . "\">\n"; } list($microseconds, $seconds) = explode(' ', microtime()); $end_time = floatval($seconds) + floatval($microseconds); $total_time_first = $end_time - $start_time; # TIME SECOND METHOD list($microseconds, $seconds) = explode(' ', microtime()); $start_time = floatval($seconds) + floatval($microseconds); for ($i = 0; $i < 100; $i++) { ?> <a href="<? echo $_SERVER['PHP_SELF']; ?>?action=<? echo $foo; ?>"> <? } list($microseconds, $seconds) = explode(' ', microtime()); $end_time = floatval($seconds) + floatval($microseconds); $total_time_second = $end_time - $start_time; # OUTPUT RESULTS echo "<p>First method took " . $total_time_first . " seconds</p>\n"; echo "<p>Second method took " . $total_time_second . " seconds</p>\n"; ?> Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php