Concatenation vs. Interpolation

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

 



Hi,

FASTER CODE!

This question involves Coding Style, Readability, Write-ability and
Performance.
Some people use the . operator to concat an string to a variable, some
people use interpolation (embeding variable into string).

=====================
1st Method (Concatenation)
$str = 'My name is ' . $name;

2nd Method (Interpolation)
$str = "My name is $name";
=====================

I know that the 1st Method is much faster, according to
some benchmarks, which one of them is available
in the book "Advanced PHP Programming, page 470".

Could we consider the 1st Method as a "Best Practice", which offers
better Performance?

I know that the performance here is not very much, but is it
considerable in a high-traffic website?

Thank you in advanced for sharing your opinions,
Behzad

[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