This is a response to troelskn. I know this isn't really the preferred use of SO, but I really want to find out more and I have more to say than can fit in short comments.
It's a pretty basic premise of the language that functions are unaware of the context in which they are used.
Really? Is this something the PHP language developers have specified, or are you inferring this from the fact that it can't be done?
This allows you to decompose your application, because each part (function) is completely isolated from its surroundings.
Isn't this why problems occur when backwards-incompatible changes are made to the language? If you can just up and change the behavior of any function, wouldn't any other function that depends on it break? Wouldn't having more insight into the context be a tool to help avoid that?
In addition to that, it is generally considered bad style to have functions output directly.
Considered by whom?
Ideally there should be just one single echo statement in your entire application.
Er. That's severely limiting. In order to achieve this, it requires having functionality that isn't built into the language and can be buggy as implemented, like a templating abstraction. Why is <someTag><?php echo sanitize($var); ?></someTag>
inferior to echo someTemplateFunction($someHugeCompiledTemplate);
?
Besides the fact that the latter has more overhead and room for bugs, doesn't it also make it harder to isolate problems (thus negating the assertion that "each part (function) is completely isolated from its surroundings")?