|
Posted by Erwin Moller on 10/06/44 11:23
Rune wrote:
> Is it best to use double quotes and let PHP expand variables inside
> strings, or is it faster to do the string manipulation yourself manually?
>
> Which is quicker?
>
> 1)
> $insert = 'To Be';
> $sentence = "$insert or not $insert. That is the question.";
>
> or
> 2)
> $insert = 'To Be';
> $sentence = $insert . ' or not ' . $insert . '. That is the question.';
>
>
> Small thing, but might as well get it right.
>
> Thanks
> /Rune
Hi,
I do not want to sound like your teacher/parent/whatever, BUT...
Why do you care about minimal optimalizations?
In practice, do you expect ANYBODY to notice the difference?
My point being:
Write code YOU like.
Write code YOU think is good readable.
And have a little trust in the language you use.
Almost ALL cases where I saw a performancedegradation is was due to poorly
constructed databasequeries, NOT because of 'slow language' constructs.
I know I am not answering your question, but I just want to point out you
better focus on other issues. :-)
To answer your question:
It depends.
I wouldn't be surprised if you get different results on PHP4.3 than on PHP5.
Or different results on W2000 and Wxp and Debian Sarge, and.. etc.etc.
To get some idea on your current setup: Just run a benchmark.
And even benchmarks can give you a wrong impression because of all kinds of
smart optimizing happing behind your back by the engine.
just my 2 cents.
And again, sorry for sounding pedantic. :P
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|