PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
toasty2
Forum Contributor
Posts: 361 Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA
Post
by toasty2 » Mon May 14, 2007 10:26 pm
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 concatenationWhich is generally quicker and which one do yall use more often?
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Mon May 14, 2007 10:34 pm
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.
CoderGoblin
DevNet Resident
Posts: 1425 Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany
Post
by CoderGoblin » Tue May 15, 2007 2:22 am
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.