[nycphp-talk] Variables syntax
Brian O'Connor
gatzby3jr at gmail.com
Sat Oct 29 02:47:01 EDT 2005
>From what I've heard using single quotes in strings and arrays help improve
speed, although very minimally and is only noticable in very large
applciations. The reason being that php does not parse for variables in
single-quoted strings, and in double quoted it does.
I personally code with method B, but I guess I should start changing (for
the reasons that Dan Cech pointed out).
On 10/28/05, Aaron Fischer <agfische at email.smith.edu> wrote:
>
> Dan Cech wrote:
>
> >I tend to go with version D:
> >
> >$print_first_name = 'You said your first_name is '.
> >$_SESSION['first_name'] .'.';
> >
> >As you can see I use single-quotes around the 'string' portions and I
> >have modified the spacing rule a little so that I don't leave a space
> >between the 'string' portions and the . concatenation operator.
> >
> >There are a few reasons I use this approach, but chief among them is
> >that it makes child's play of spotting variables, especially in a
> >syntax-highlighting editor. If they're embedded within a string they're
> >much harder to spot (for me at least).
> >
> >
> >
>
> That is indeed one of the drawbacks I have noticed as well, if I embed
> the var within the string I lose the syntax highlighting which make the
> variables much harder to spot (for me as well).
>
>
> >In the end it comes down to personal preference, my testing indicates
> >that the performance difference between single-quotes, double-quotes or
> >double-quotes with complex (curly) braces is not large enough to really
> >be worth considering unless you are talking about a LOT (> 100,000)
> >embedded variables. I would suggest going with whatever makes your
> >code the most consistent and easiest to maintain.
> >
> >Dan
> >
> >
> >
> Benchmark testing is something I have on my list of "to learn about"
> stuff. It hasn't been mentioned in the books that I have (again, I
> suppose that's further justification for more books).
>
> -Aaron
>
>
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>
--
Brian O'Connor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20051029/dcaa630d/attachment.html>
More information about the talk
mailing list