Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance: " or ' PHP [duplicate]

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"])

like image 557
Marnix Bouhuis Avatar asked Dec 14 '15 15:12

Marnix Bouhuis


1 Answers

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!

like image 133
Jens A. Koch Avatar answered Oct 14 '22 02:10

Jens A. Koch