DEV Community

loading...

Discussion on: 4 PHP Tricks to Boost Script Performance

Collapse
vinyvicente profile image
Vinicius

And about the simple or double quotes? What your opinion about the performance of both?

Collapse
devmount profile image
Andreas Author

Do you mean quotes? If you're interested, I could add a ' vs " test...

Collapse
vinyvicente profile image
Vinicius

Yes, quotes, my bad. Did you make some implementation of it?

Thread Thread
devmount profile image
Andreas Author

Not yet, but I will create a test with the current PHP version and will come back when I have results šŸ‘šŸ»

Thread Thread
devmount profile image
Andreas Author

In the meantime, see this:

Thread Thread
devmount profile image
Andreas Author

I did a quick benchmark, see this comment:

I can confirm that the single vs. double quotes myth is really just a myth. At least for the PHP 7.2+ (maybe this originates from ver early PHP versions). I did a quick benchmark:

You can say with caution, that in average, double quotes are slightly (and I really mean very slightly!) faster than single quotes. We're talking about a max of 2ms on 5 million iterations... Obviously only, if no variable is replaced.

Thread Thread
vinyvicente profile image
Vinicius

Great! Just for the convention is used so. Thanks, Andreas.

Thread Thread
devmount profile image
Andreas Author

My pleasure šŸ˜Š