Php profiling tip 1
Thursday, June 21st, 2007Someone at work pointed this out to me today, so here it is for google’s benefit…
When coding php pages you often have to manipulate strings and print them, with select pieces of data, so that the user can see them.
There are 2 different ways to do this:
$var = 'This is a variable : '.$data;
and
$var = "This is a variable : $data";
In the first case, you just concat the 2 elements together, whereas in the second case, php does the substitutions by it’s self.
The interesting part is that the first construct is over 4 times faster than the second….
More info (in French) here