Page 1 of 1

double quotes vs. single quotes with concatenation

Posted: Mon May 14, 2007 10:26 pm
by toasty2
Which is better? I hear somewhere that single quotes are faster, but are they still faster when you use concatenation? Like:

Code: Select all

$string = "Stuff: $stuff"; // Double quotes
$string = 'Stuff: '.$stuff; // Single quotes with concatenation
Which is generally quicker and which one do yall use more often?

Posted: Mon May 14, 2007 10:34 pm
by John Cartwright
I use the latter because it is more readable to me. Execution speed of single quotes vs. double quotes is extremely neglible, I really wouldn`t worry about it.

Posted: Tue May 15, 2007 2:22 am
by CoderGoblin
I agree that the difference should be based only on personal preference. I tend to use

Code: Select all

"alsd hfaj hflkj hsaklf {$myvar} yxc vyx"
but this is do provide consistancy when using array variable which don't normally work in double quotes without the squigglies.

Whatever method you use the key thing is to remain consistent.