Concatenation vs. Interpolation

From: Date: Sat, 11 Aug 2007 07:21:25 +0000
Subject: Concatenation vs. Interpolation
Groups: php.general 
Request: Send a blank email to php-general+get-260675@lists.php.net to get a copy of this message
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

« previous php.general (#260675) next »