Home > General Articles, PHP > Quotes – All about variable evaluation

Quotes – All about variable evaluation

The doubt on whether to use double or single quotes for static strings,  has been a heated discussion on many a discussion groups. As of late I did a small bench mark, and has found that the encapsulation of variables in double quoted string is a slight higher load than concated string, even when the static string is quoted in double, whereas the most efficient is to specify single quotes for quoting static string.

The results which I got over various servers in different class showed more or less the same trend, with the Single quotes having the least time, Double quotes with concatenation following with a negligible difference, Double quotes without braces, with a whopping 10 to 12 times that of the lowest time, and Double quotes with brace evaluation even slower than that. Your mileage may vary, and may depend on the no of running processes, available memory and running php version. I would appreciate if some of you will report back with the values from possible different systems, such that we can aggregate a tabular sheet somewhere.

The script which I used for benchmarking the same can be viewed here

Categories: General Articles, PHP Tags:
  1. No comments yet.
  1. No trackbacks yet.

six + four =