开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜