Reply to Re: [PHP] String format problem

Your name:

Reply:


Posted by "Mark Rees" on 10/11/59 11:25

> 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация