Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #14465

Re: $-sign in form input names?

From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups comp.lang.php
Subject Re: $-sign in form input names?
Date 2014-11-04 21:42 +0100
Organization solani.org
Message-ID <m3bdnm$qjg$1@solani.org> (permalink)
References <996e3930-f711-4338-9093-07115af47380@googlegroups.com> <m398il$m28$1@dont-email.me> <cbr824Fmk87U1@mid.individual.net> <m3a5jf$7tf$1@solani.org> <m3ange$3mv$1@dont-email.me>

Show all headers | View raw


Jerry Stuckle wrote:

> On 11/4/2014 4:17 AM, Christoph M. Becker wrote:
>> J.O. Aho wrote:
>>
>>> As the double quotes will make the string to be parsed every time, which
>>> causes some slight overhead.
>>
>> But see
>> <http://nikic.github.io/2012/01/09/Disproving-the-Single-Quotes-Performance-Myth.html>.
> 
> I could go on, but the bottom line is - he is obviously biased, and his
> arguments are full of holes.  I agree with J.O. - single quotes are
> better unless you need to parse the strings.

Obviously you have not really understood the issue -- and neither has
J.O.  A double quoted string is "parsed" (actually, lexed) only *once*.
 A single quoted string is also lexed once.  So only the lexing time
could make a difference (and even this could be ignored when some kind
of bytecode cache is available; OPcache is enabled by default since PHP
5.5.0).

Anyhow, even a single quoted string has to be scanned for escapes ('\\',
'\''), so there is presumably not much difference (if we ignore
interpolation, what is not available for single quoted strings, anyway).
 Nikita's quick benchmark confirms this presumption.  A more thorough
measurement is left to the unbelieving reader.

It should be noted that this behavior does not apply to old PHP
versions, see
<http://blog.golemon.com/2006/06/how-long-is-piece-of-string.html>.

BTW: I rarely use double quoted strings.

-- 
Christoph M. Becker

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

$-sign in form input names? sonnichjensen@gmail.com - 2014-11-03 07:23 -0800
  Re: $-sign in form input names? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-11-03 15:54 +0000
  Re: $-sign in form input names? Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-04 01:02 +0000
    Re: $-sign in form input names? "J.O. Aho" <user@example.net> - 2014-11-04 06:55 +0100
      Re: $-sign in form input names? "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-04 10:17 +0100
        Re: $-sign in form input names? Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-04 09:23 -0500
          Re: $-sign in form input names? gordonb.2w35u@burditt.org (Gordon Burditt) - 2014-11-04 09:35 -0600
            Re: $-sign in form input names? Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-04 10:37 -0500
          Re: $-sign in form input names? "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-04 21:42 +0100
            Re: $-sign in form input names? Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-04 17:01 -0500
              Re: $-sign in form input names? "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-11-04 23:46 +0100
                Re: $-sign in form input names? Jerry Stuckle <jstucklex@attglobal.net> - 2014-11-04 21:19 -0500
        Re: $-sign in form input names? Matthew Carter <m@ahungry.com> - 2014-11-04 09:31 -0500

csiph-web