I'd like to comment that this is an important issue in ASP. This is because with ASP the script engine has to check which language to parse (in most cases, VBscript).
In ASP it is therefore better to define your language in the top of the page, but mode switching between HTML/ASP still slows performance (in my experience).
As I understand it, PHP is a scripting language on it's own, so it is better to parse as few code as possible for better performance.
MB wrote:
I can't believe this post has been here for this long without a "real" answer....
Just for the record, after asking myself the same question a few months back, and reading this thread (among others), I did some benchmarking.
It is MUCH more efficient to code a mixture. If PHP doesn't need to process the code, let the web server just push the bits out. In my test cases it was up to 10x slower to let PHP spit out the whole thing, as opposed to jumping back and forth between HTML and PHP.
Another advantage to doing mixed code, at least in some cases, is that you can use an HTML editor like GoLive and actually do some formatting in "WYSIWYG". At least as much as an editor allows.