PHP capture print/require output in variable

后端 未结 2 818
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 03:04

Is it possible to add the output of print() to a variable?

I have the following situation:

I have a php file which looks something like this:

2条回答
  •  被撕碎了的回忆
    2020-12-07 03:33

    You can use output buffering to capture any output send ob_start() http://us3.php.net/ob_start. You capture the output with ob_get_flush() http://us3.php.net/manual/en/function.ob-get-flush.php.

    Or you could just return the output from title.php like so:

    Page heading';
    return $content;
    

提交回复
热议问题