Capture STDOUT from included file to variable
How to capture everything what leaves included file 开发者_如何学Pythonto variable or another file.
Output buffering is the way to go.
<?php
ob_start(); // Start buffering output
include '/path/to/file/';
$myVariable = ob_get_clean(); // Put the buffered output
// into $myVariable and clear
// the output buffer
http://www.php.net/manual/en/function.ob-start.php
http://www.php.net/manual/en/function.ob-get-clean.php
Using output buffers: http://www.php.net/manual/en/function.ob-get-contents.php
精彩评论