Re: ECHO or concatenation with single quote, for performance?



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!

.



Relevant Pages

  • Re: script question.
    ... This script doesn't seem to do anything other than echo the results back ... Subject: script question. ... Thanks Jean-Marc but how do I get the commas in the result? ... The authorized recipient of this information is prohibited ...
    (AIX-L)
  • Re: total size of files
    ... echo Total=%Total% ... If desired then you can expand the above batch script so that it scans a ... Note the /-C switch to remove the commas from the listing. ... problems because it is also a command line delimiter. ...
    (microsoft.public.scripting.vbscript)
  • Re: Name of the day in different languages.
    ... Only when using echo for printing things out. ... to be separated by commas: ... printf(' Klockan är: %s', strftime('%R')); ...
    (alt.php)
  • Re: [PHP] concatenating with "." or ","
    ... Yeti wrote: ... What I am still wondering about is if it is faster to use commas or ... the "" brackets? ... echo "test"; ...
    (php.general)
  • Re: Jaguar Tiger Panther BW G3
    ... "Newsgroups" header field, separated by commas. ... Mail: echo 36199371860304980107073482417748002696458P|dc ...
    (comp.sys.mac.system)