Search code examples
phpperformancedouble-quotessingle-quotes

Performance: " or ' PHP


I'm working on a big project in php and I need to make sure it's all fast. So I'm wondering: what is faster to use, " or ' ? (Eg: $_SESSION['example'] or $_SESSION["example"])


Solution

  • You shouldn't even care about this. It makes no real difference. No practical impact.

    http://nikic.github.io/2012/01/09/Disproving-the-Single-Quotes-Performance-Myth.html

    https://speakerdeck.com/dshafik/phpaustralia-2015-php-under-the-hood


    Lets use the same benchmark data from the post by Mark Smit:

    For a real speed benchmarks between quotes you can look at http://www.phpbench.com/

    Q: Is a there a difference in using double (") and single (') quotes for strings. Call 1'000x

    A: In today's versions of PHP it looks like this argument has been satisfied on both sides of the line. Lets all join together in harmony in this one!