niche Posted October 31, 2010 Share Posted October 31, 2010 which is best practices:echo '<input type="hidden" name="' . $clistknum . '-' . $id . '" value="' . $price . '" />'; orecho '<input type="hidden" name="' . $clistknum . "-" . $id . '" value="' . $price . '" />';why (or does it really matter)? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 31, 2010 Share Posted October 31, 2010 It's going to be very slightly faster to use single-quotes. Link to comment Share on other sites More sharing options...
boen_robot Posted October 31, 2010 Share Posted October 31, 2010 In your case, I'd write it as echo "<input type='hidden' name='{$clistknum}-{$id}' value='{$price}' />"; Assuming single quotes in the output XHTML doesn't bother you. Concatenation itself is a larger bottleneck than quotes... well... it's still a very marginally smaller one, so yeah... it doesn't really matter. Link to comment Share on other sites More sharing options...
jeffman Posted October 31, 2010 Share Posted October 31, 2010 Will no one make the argument for whichever style is easier to read? In this case, I can read boen's and get the gist of the output a lot more quickly than the concatenated version.Unless you plan to output 100,000 iterations of this string all at once, developer efficiency trumps program efficiency. IMHO. Link to comment Share on other sites More sharing options...
niche Posted October 31, 2010 Author Share Posted October 31, 2010 justsomeguy, boen_robot, Deirdre's Dad, thank-you very much for your help. As usual, I received unexpected benefits from each post.Niche Link to comment Share on other sites More sharing options...
ShadowMage Posted November 1, 2010 Share Posted November 1, 2010 Will no one make the argument for whichever style is easier to read? In this case, I can read boen's and get the gist of the output a lot more quickly than the concatenated version.I think that depends more on the syntax highlighting. In plain black 'n white text boen's code is indeed easier to read, however, with the highlighting that my editor uses, it's easier for me to read the concatenated version:echo "<input type='hidden' name='{$clistknum}-{$id}' value='{$price}' />";vsecho "<input type='hidden' name='".$clistknum."-".$id."' value='".$price."' />";My editor doesn't color variables inside strings, maybe other editors do, but mine doesn't so I usually write concatenated strings. Link to comment Share on other sites More sharing options...
jeffman Posted November 1, 2010 Share Posted November 1, 2010 I wasn't trying to take sides in any cosmic sense. Just saying that developer efficiency should be a consideration, whatever tool gets you there.In-house practices (not mentioned before) are also worthy of consideration. If you have to update someone else's code, and he doesn't do stuff the way the rest of the shop does, that's going to cut productivity. Link to comment Share on other sites More sharing options...
niche Posted November 1, 2010 Author Share Posted November 1, 2010 While we're back on this subject, what's the reference for use of curly brackets in this situation?Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted November 1, 2010 Share Posted November 1, 2010 http://www.php.net/manual/en/language.type....string.parsing Link to comment Share on other sites More sharing options...
niche Posted November 1, 2010 Author Share Posted November 1, 2010 Thanks again justsomeguy. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.