Re: Code optimization: single vs. double quotes?
| From: | Justin French | Date: | Tue, 28 Oct 2003 05:30:20 +0000 |
| Subject: | Re: Code optimization: single vs. double quotes? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167840@lists.php.net to get a copy of this message | ||
On Tuesday, October 28, 2003, at 09:29 AM, Chris Shiflett wrote:
--- Justin French <justin@indent.com.au> wrote:Yes, they are superfluous in this example, but not because we're in double quotes. You can ONLY use complex strings inside double quotes, AFAIK: <? $str = "blah"; echo "{$str}<br />"; // echos blah<br /> echo '{$str}<br />'; // echos {$str}<br /> ?> As I'm sure you're aware, the use of the {braces} is to allow complex combinations of variables, like found in the manual http://www.php.net/types.string In the above example, they are indeed not needed, but I've gotten into the habbit of using them on all strings for a few reasons; - the fact that there can be no confusion (either human or PHP) over what I mean - PHP will be non-greedy when looking for the valid variable name - since i'm now in the habbit, I never have to debug examples where it IS needed :)a) echo "<td bgcolor='{$bgcolor2}'> </td></tr>";The curly braces are superfluous here, since you are using double quotes. I'm not sure if you like having them there, but I think that less syntax yields a simpler and cleaner appearance.
However, I hate single quotes around HTML attributes, so I can't bring myself to use that format anyway. :-)Well, that's where we come down to personal opinion... personally, seeing \" 100's of times in a script doesn't turn me on at all :) Justin French