Re: ECHO or concatenation with single quote, for performance?
- From: "L. Berger" <straightfwd007@xxxxxxxxx>
- Date: 30 May 2007 16:28:33 -0700
The fastest would be something like
echo 'some text ', $aVar, ' some more text ', $anotherVar;
Thanks, I had no idea echo could work with simple commas! Some testing
with microtime (just back of the envelope, nothing scientific) reveals
that it is indeed the fastest. Here's what I had:
OPTION 1: echo 'something and more' . $i . $i+100 . 'something else
and then some';
OPTION 2: echo 'something and more' , $i , $i+100 , 'something else
and then some';
OPTION 3: something and more' <?php echo $i; ?><?php echo $i+100; ?
something else and then some
Option 2 outperforms the others. 1 and 2 are almost the same, but 2 is
usually just a little bit faster, especially for more variables.
Option 3, which calls echo many times is markedly slower.
Hope this helps someone!
.
- References:
- ECHO or concatenation with single quote, for performance?
- From: L. Berger
- Re: ECHO or concatenation with single quote, for performance?
- From: Michael Fesser
- ECHO or concatenation with single quote, for performance?
- Prev by Date: Re: Outside variables needed inside class
- Next by Date: Re: Intense CPU strain....suggestions
- Previous by thread: Re: ECHO or concatenation with single quote, for performance?
- Next by thread: cURL firestarter help needed
- Index(es):
Relevant Pages
|