You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Arnon Weinberg <ar...@back2front.ca> on 2012/04/30 18:29:37 UTC

Include() vs. TrapInclude()

Just thought I'd post this for anyone else that might run into a similar 
situation...

The documentation seems to suggest that Include() and TrapInclude() are 
interchangeable, apart from the buffering that happens.  That is:
<%
   $Response->Include('test.inc');
%>
should be equivalent to:
<%=
   ${$Response->TrapInclude('test.inc')}
%>
with respect to output.

However, TrapInclude() creates a local output buffer, whereas Include() 
does not, so certain methods behave differently if they run inside an 
Include() file vs. a TrapInclude() file.  For example, 
$Response->Clear(), $Response->End(), and $Response->Flush() produce 
different results.  Their behaviour is a natural consequence of local 
output buffering, so just something to be aware of.

Also, when Buffering is turned on, the behaviour of $Response->End() is 
not as expected given a local output buffer, as it ends the program, but 
does not flush the caller's buffer, so this may be a minor bug.


-- 
-------------------------------------------------------------------------------
Arnon Weinberg
www.back2front.ca



---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org