Every so often, I get asked about whether it is really worth it to chase double quotes and constructs like
print "foo $bar baz", and replace them with something like
echo 'foo', $bar, 'baz', or even to remove all those big heredoc strings so convenient for large texts.
Of course, most of the time, spending hours to fine comb code in search of this will result in less of a speedup than rethinking just one SQL query, but the answer is still that, yes, in the infinitesimal scale, there is something to be gained. Even with string reformatting ? Yes, even that. But only if you are not using an optimizer.
Just don't take my word for it, Sara Golemon explained it years ago with her "How long is a piece of string" post, in 2006.
Note that her suggestion about
apc.optimization is no longer relevant with APC 3.x, though, as this has been removed in APC 3.0.13, with optimizations now always on.
2011-02 UPDATE: as explained by TerryE in the comments, while this applied with older PHP versions (remember, this was written in 2006) which one still found live when reviewing older sites for upgrades, it does not apply to current versions of PHP 5.2.x and 5.3.x.
2010-04 UPDATE: the initial version of this post incorrectly mentioned phpdocs instead of heredocs. Thx
dalin for pointing out the error.
phpdoc-type comments DO come at a cost but that's when using the
which actually interprets them to add information to
ReflectionParameter instances, and this has nothing to do with string processing.