Connecting Tech Pros Worldwide Help | Site Map

$string .= $new vs $string = $string . $new performance

  #1  
Old July 3rd, 2008, 11:45 PM
Leigh Finch
Guest
 
Posts: n/a
Hey Guys,
Quick question about the PHP compiler, is there any performance
difference between

$string .= $new;

and

$string = $string . $new;

Does the compiler see them as equivalent and optimize to the later, or
does concatenate and then copy?

Can anyone point me to some documentation on this, I havent been able to
find anything on this particular topic?

Cheers
Leigh Finch
  #2  
Old July 3rd, 2008, 11:55 PM
Michael Fesser
Guest
 
Posts: n/a

re: $string .= $new vs $string = $string . $new performance


..oO(Leigh Finch)
Quote:
>Quick question about the PHP compiler, is there any performance
>difference between
>
>$string .= $new;
>
>and
>
>$string = $string . $new;
>
>Does the compiler see them as equivalent and optimize to the later, or
>does concatenate and then copy?
Don't worry and google "premature optimization" if you want to.

Micha
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
StringBuilder Performance vs. String Concatenation Kevin C answers 38 November 22nd, 2005 06:06 AM
String vs new String Grant Wagner answers 8 July 23rd, 2005 09:27 PM
StringBuilder Performance vs. String Concatenation Kevin C answers 37 July 21st, 2005 11:18 AM