How speed improving using single quotes instead of double quotes really is
Articles about speeding up your php are really frequent on the net, and every single one of them includes using single quotes instead od double quotes, at least when you don’t have any variables in that section you are echoing. I did a little test and here is the result.
According to all those articles php loads faster when echoing something in single quotes then echoing something in double quotes because as we all know when we wrap a variable in single quotes it’s considered as normal text and that means the php engine will just show it without checking for variables in it, on the other side if it’s wrapped in double quotes it’s gonna check if there are variables in it which makes the process longer. That’s true, but how much difference does it make…
I first tried with a small amount of text (few lines). The single quote wrapped text needed from 40ms-70ms and the same result was for double quotes wrapped text. But ok, those are just few lines, no one said it’s much faster when we are echoing small text. So, then i tested it with 3.32MB of pure text. Here is the result…
This is the result for single quotes, 17.59 seconds. So naturally we should expect at least one second slowed loading with the next test, double quotes.
You probably think i forgot to switch to double quotes, don’t worry i didn’t So the result for double quotes is 17.06 seconds.
I made numerous tests with both single and double quotes wrapped text. Sometimes single quotes was a bit faster and sometimes double quotes was a bit faster. The testing was made on a WAMP server on my PC, but i also tested in on the TutsValley’s server and the result are simillar. I needed between 42s and 44s (yea i got a slow internet connection) for both of them, and again sometimes single quotes ware faster and sometimes double quotes ware faster. So how does using single quotes really help us? I don’t know… In my opinion it DOESN’T.
- Client side filtering data with jQuery
Did you absolutely LOVE this article... share it!