Re: Re[2]: [PEAR-DEV] [PEPr] +1 for XML::XML_Feed_Parser
| From: | Justin Patrin | Date: | Mon, 24 Oct 2005 16:06:42 +0000 |
| Subject: | Re: Re[2]: [PEAR-DEV] [PEPr] +1 for XML::XML_Feed_Parser | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-40272@lists.php.net to get a copy of this message | ||
On 10/23/05, techtonik <techtonik@tut.by> wrote:
> ||*()*|| [\..konnichi wa, ogenki desu ka, Justin../]
>
> JP> http://pear.reversefold.com/strings/index.php
>
> >> >
> >> As far as I can see Coding Standards do not say you should use
> >> concatenation over inlining, end of the story. Some arguments were given
> >> in favor of the former, in the end the developer decides which form to use.
> >>
>
> JP> And may I point out that I *always* say that I *prefer* single quotes,
> JP> not they the developer *must* use them.
>
> But don't you find it annoying to always say the same thing? =)
Yes, but what I'm doing is helping people be better PHP developers.
>
> As for your script - the worst scenario I can get is 10% difference on
> single $ included in both strings resulting in a 0.5 seconds delay on a
> 100000 lines script. Considering real working script even in this
> worst (and unrealistic) scenario the ratio of overall execution time to
> this stuff would be at least hundred to one. Even if you try to
> multiply this 0.5s by amount of simultaneous script executions (the
> same hundred, for example) to get some real grounds for this kind of
> recommendations - on realistic script your server will be drop dead long
> ago until you reach this limit. =) So the main point is what this stuff
> just doesn't worth developer's time.
>
I didn't say it was a huge difference. The difference between $a++ and
++$a is also not that big, but it makes a difference. Add up all the
little tricks and you can get significant speedups. At least I have
shown, for all to see, that what I've been saying is true (although I
shouldn't have had to since other well-known developers also vouched
for this and you should have been able to test it yourself as well).
And you're still ignoring that concatenation is easier to audit. *All*
syntax highlighters will highlight concatenation. Only some highlight
in-string vars correctly. Besides that, it's also simpler to be able
to skip over single quoted vars when looking for things like XSS or
SQL injection attacks. It also means that there are no special chars
in the string to watch out for.
Using " is also more error-prone when dealing with complicated vars
(and it can't be used for *really* complicated ones). On top of this
it tends to promote bad array syntax ($arr[key] instead of
$arr['key']).
For all of these reasons (and probably some I'm missing) ' should be
preferred over ".
--
Justin Patrin