Originally posted by Roger Ramjet
As a general rule, php pages run faster than any other type of dynamic pages such as dhtml, asp, etc.
Hmmm... DHTML.... that runs client-side (being Javascript) so doesn't suffer network lag. Of course, if it needs to call on server resources, it has to request them and that's a delay, but then there's also the issue of what the server is running....um, how did that get in the list again?
Oh, and it also assumes that the PHP programmer is reasonably competent.
In the original poster's two snippets - although it is hard to compare them since they're doing different things - the latter I have found to be approximately twice as slow as straightforwad equivalents (concatentation, comma-separated arguments, or escaping from PHP), but (a) the relative timings seem to change from PHP version to PHP version as the internals are dickered around with and I really can't be bothered rewriting everything for every new version that's installed, and (b) the saving is only on the order of milliseconds per day and I've got far more important things to do than waste seconds of my time on eliminating milliseconds of server time: my time is more expensive for a start, and no-one is going to notice those milliseconds. Oh, and (c), optimisers can really change things.
This is an optimisation issue that's so far below the noise threshold it's not worth worrying about. The effort is better spent making the code as a whole sleek and simple. Remember that source code is intended to be readable and writable by humans. So use whichever is the most natural in whatever the current context is.