RE: [PHP] jumping between php and html or using echo for printing html-tags.
| From: | Daevid Vincent | Date: | Fri, 07 Feb 2003 00:49:47 +0000 |
| Subject: | RE: [PHP] jumping between php and html or using echo for printing html-tags. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134698@lists.php.net to get a copy of this message | ||
Fatal error: Call to undefined function: floatval() in
/home/dae51d/public_html/examples/echotest.php on line 14
> -----Original Message-----
> From: Chris Shiflett [mailto:shiflett@php.net]
> Sent: Thursday, February 06, 2003 2:40 PM
> To: anders thoresson; php-general@lists.php.net
> Subject: Re: [PHP] jumping between php and html or using echo
> for printing html-tags.
>
>
> --- anders thoresson <listor@thoresson.net> 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
>