Re: String format problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> In fact, this is a poor example since the difference gets larger with
longer
> string and more arguments.  When you use dots, the interpreter has to
> actually concatenate the string, looking for memory to do so and freeing
it
> up afterwards.  This takes time.  With commas, each argument is sent to
the
> output stream as soon as it is found, no further processing is needed in
> between.
>

I have been wondering about this topic for a few months now, so thanks for
this fascinating explanation. Is this the only difference between using .
and , as concatenation operators>


> Then the single vs. double quotes:
>
> echo 'uno ' , ' dos ' , ' tres ': 0.94
> echo "uno " , " dos " , " tres ": 6.76
>
> Notice that when variables are involved, the difference in between echoing
> with arguments separated with commas and separated with dots is more than
9
> times faster for the commas.    Using double quotes with variable
expansion
> is almost 4 times slower than the commas, but is still faster than
> concatenating them externaly with dots.   Using heredoc-style strings is
not
> so bad compared to double quotes.

Never heard of heredoc before. What is it for? I have read
http://uk.php.net/types.string

and can only imagine that it is for laying out complex or long strings more
clearly

>
> So, if you are sending out the rule would be:
> Use echo, not print.   Separate arguments with commas.
>
> Now, if you are not using echo, for example, concatenating to a variable,
> the best is to use variable expansion inside double quoted or heredoc
> strings.   Concatenating with dots is more than twice as slow.
>
> Satyam

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux