使用 ob_start() 和 ob_get_contents() 和 ob_end_clean() 请参阅 PHP 手册http://php.net/manual/en/function.ob-get-contents.php下页上的示例 #1
第一次看起来很吓人,但效果很好。只要确保每次使用 ob_start() 时总是使用 ob_end_clean()
ob_start(); // start capturing output.
do_action('any_action_you_want');
$save_output_here = ob_get_contents(); // the actions output will now be stored in the variable as a string!
ob_end_clean(); // never forget this or you will keep capturing output.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3120 次 |
| 最近记录: |