This is a discussion on RE: [PHP] Code optimization: single vs. double quotes? within the PHP General forums, part of the PHP Programming Forums category; olinux <mailto:olnx@yahoo.com> on Friday, October 24, 2003 9:41 PM said: >>> echo &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
olinux <mailto:olnx@yahoo.com>
on Friday, October 24, 2003 9:41 PM said: >>> echo "<td bgcolor=\"$bgcolor2\"> </td></tr>"; > > uggh - apparently you've never had to redesign a > site/application that uses this style. This is one > table cell, but when you work this style through a big > app, it's a huge pain (waste of time) to make any > changes. Apparently. What do you recommend? c. -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/ |
|
|||
|
On Tuesday, October 28, 2003, at 04:29 AM, Chris W. Parker wrote:
> olinux <mailto:olnx@yahoo.com> > on Friday, October 24, 2003 9:41 PM said: > >>>> echo "<td bgcolor=\"$bgcolor2\"> </td></tr>"; >> >> uggh - apparently you've never had to redesign a >> site/application that uses this style. This is one >> table cell, but when you work this style through a big >> app, it's a huge pain (waste of time) to make any >> changes. > > Apparently. What do you recommend? You have plenty of options... a & b would be my preference: a) echo "<td bgcolor='{$bgcolor2}'> </td></tr>"; b) echo "<td bgcolor='$bgcolor2'> </td></tr>"; c) echo '<td bgcolor="'.$bgcolor2.'"> </td></tr>'; d) echo "<td bgcolor='".$bgcolor2."'> </td></tr>"; Justin French |
|
|||
|
--- Justin French <justin@indent.com.au> wrote:
> 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. :-) Chris ===== My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp |
|
|||
|
On Tuesday, October 28, 2003, at 09:29 AM, Chris Shiflett wrote:
> --- Justin French <justin@indent.com.au> wrote: >> 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. 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 :) > 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 |