[PHP] jumping between php and html or using echo for printing html-tags.
Which is more efficient: function admin_menu() { echo B Meny /BBR; echo A HREF=\ . $_SERVER['PHP_SELF'] . ?action= . MANAGE_MEMBERS . \Medlemmar/ABR; echo A HREF=\ . $_SERVER['PHP_SELF'] . ?action= . MANAGE_ALBUMS . \Album/ABR; echo A HREF=\ . $_SERVER['PHP_SELF'] . ?action= . INITIAL_PAGE . \Huvudmeny/ABR; echo A HREF=\ . $_SERVER['PHP_SELF'] . ?action= . LOG_OUT . \Logga ut/ABR; } or function admin_menu() { ? B Meny /BBR A HREF=?=$_SERVER['PHP_SELF']??action=?php echo(MANAGE_MEMBERS) ;?Medlemmar/ABR A HREF=?=$_SERVER['PHP_SELF']??action=?php echo(MANAGE_ALBUMS) ;?Album/ABR A HREF=?=$_SERVER['PHP_SELF']??action=?php echo(INITIAL_PAGE) ;?Huvudmeny/ABR A HREF=?=$_SERVER['PHP_SELF']??action=?php echo(LOG_OUT);?Logga ut/ABR ?php } Any reasons other than speed to choose either? -- anders thoresson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] jumping between php and html or using echo for printing html-tags.
--- 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 pFirst method took . $total_time_first . seconds/p\n; echo pSecond 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
Re: [PHP] jumping between php and html or using echo for printing html-tags.
--- Chris Shiflett [EMAIL PROTECTED] wrote: 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 results went the other way when I tested this using mod_php rather than the CLI, and there was a larger difference between the two. So, test it in your own environment, because YMMV. :-) Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] jumping between php and html or using echo for printing html-tags.
Fatal error: Call to undefined function: floatval() in /home/dae51d/public_html/examples/echotest.php on line 14 -Original Message- From: Chris Shiflett [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 06, 2003 2:40 PM To: anders thoresson; [EMAIL PROTECTED] Subject: Re: [PHP] jumping between php and html or using echo for printing html-tags. --- 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 pFirst method took . $total_time_first . seconds/p\n; echo pSecond 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] jumping between php and html or using echo for printing html-tags.
--- Daevid Vincent [EMAIL PROTECTED] wrote: Fatal error: Call to undefined function: floatval() in /home/dae51d/public_html/examples/echotest.php on line 14 Please try to make an effort and do a little research of your own before asking the list: http://www.php.net/manual/en/function.floatval.php Upgrade to at least 4.2, or use this alias of floatval(): http://www.php.net/manual/en/function.doubleval.php Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php