DEV Community

Discussion on: PHP Perfomance optimization

Collapse
 
nemutaisama profile image
Andrey Ageev

Hey! Did it with pleasure, just because "single vs double quotes" thing makes me crazy. There is another old good article, that shows difference from inside nikic.github.io/2012/01/09/Disprov...

And just to make examples fully correct - concatenation is bit faster with only one variable, but it slows down with each variable you add.

And after all - according to test on php.net, using single quotes instead of double quotes is 0,5ms faster for 1 million strings, but, how many strings you have in your project? If amount for each page load is close to at least 10k strings - maybe it's time for some refactoring?

Thread Thread
 
ilvalerione profile image
Valerio • Edited

In my way of thinking it's more about habits than refactoring. I study new things and write articles to improve my habits. If my skills improve, then slowly the applications I'm working on will change for the better.

I don't think the impact on performance is business critical, so I don't think a refactoring task is necessary. Invest in skills and you (or your collaborators) will get the same result automatically.

Thread Thread
 
nemutaisama profile image
Andrey Ageev

I understand your point, and fully agree. I think it's again problem that i can't explain what's on my mind, damn my bad english ). I just trying to say that it's not so much strings in enough good designed project, and using "fastest" quotes for each case won't give you real profit. IMHO good choice is select quotes for better readability and team codestyle.

Thread Thread
 
devmount profile image
Andreas

*sneaks in and whispers* As long as no variables are replaced, there is no significant difference between single and double quotes. I did a quick benchmark today with PHP 7.4:

See discussion in my recent article about PHP performance optimization:

*sneaks out*