is there anyway to call lambda function with html contents?
function sample($test1, $test2, $inner_html) {
$html = call_user_func($inner_html);
echo $test1 . ' ' . $test2 . ' ' . $html;
}
sample('test1',开发者_开发问答 'test2', function(){
echo 'first test.'
?>
<b>this is a test.</>
<?
echo 'last test.';
});
If you put something out you can only get that output if you buffer the output using the output control’s ob_start
:
function sample($test1, $test2, $inner_html) {
ob_start();
$returnValue = call_user_func($inner_html);
$output = ob_get_clean();
echo $test1 . ' ' . $test2 . ' ' . $output;
}
精彩评论