开发者

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜