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"]
)
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!
You should use ' because everything within " is analized, which makes it perform a lot slower. Right now magic quotes are even depricated. More information about that can be found on the php website
For a real speed benchmarks between quotes you can look at phpbench
'
or "
... –
Antichrist © 2022 - 2024 — McMap. All rights reserved.
"
is very slightly (~4%) faster. But note: this is probably a case of very premature optimization. – Crustal'
need to be analysed for escape characters – Aphorism