ob_start() 和 ob_get_clean() 的使用

kia*_*shi 3 wordpress buffer

我通常这样编码:

$output .= 'custom code';
    $output .= 'another line of custom code';
$output .= 'more code';     

return $output;
Run Code Online (Sandbox Code Playgroud)

现在我想使用ob_start(),ob_get_contents()ob_get_clean(). 在我的示例中使用它的最有效方法是什么?

Geo*_*dis 7

这将返回与您给出的示例相同的内容:

ob_start();
echo 'custom code';
echo 'another line of custom code';
echo 'more code';
return ob_get_clean();
Run Code Online (Sandbox Code Playgroud)