开发者

Capture STDOUT from included file to variable

开发者 https://www.devze.com 2023-02-20 15:54 出处:网络
How to capture everything what leaves included file 开发者_如何学Pythonto variable or another file.Output buffering is the way to go.

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

精彩评论

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