Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress ob_start()和ob_get_clean()的使用_Wordpress_Buffer - Fatal编程技术网

Wordpress ob_start()和ob_get_clean()的使用

Wordpress ob_start()和ob_get_clean()的使用,wordpress,buffer,Wordpress,Buffer,我通常这样编码: $output .= 'custom code'; $output .= 'another line of custom code'; $output .= 'more code'; return $output; 现在我想使用ob\u start(),ob\u get\u contents()和ob\u get\u clean()。 在我的示例中使用它最有效的方法是什么?这将返回与您给出的示例相同的结果: ob_start(); echo 'custom

我通常这样编码:

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

return $output;
现在我想使用
ob\u start()
ob\u get\u contents()
ob\u get\u clean()

在我的示例中使用它最有效的方法是什么?

这将返回与您给出的示例相同的结果:

ob_start();
echo 'custom code';
echo 'another line of custom code';
echo 'more code';
return ob_get_clean();