Home  >  Article  >  Backend Development  >  A function that captures function output_PHP Tutorial

A function that captures function output_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:57:02913browse

I just wrote a simple function to capture the output of any function. It is also a core of the general template system.

Copy code The code is as follows:

/**
* Capture the output of a function
* example:get_output(array($this,'test'));
*/ 
function get_output($array)
{
ob_start();
call_user_func($array);
return ob_get_clean();
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317944.htmlTechArticleA simple function just written to capture the output of any function. It is also a core of the general template system. Copy the code The code is as follows: ? /** *Capture the output of a function *...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn