开发者

is there anyway to call lambda function with html contents?

开发者 https://www.devze.com 2023-01-27 18:54 出处:网络
function sample($test1, $test2, $inner_html) { $html = call_user_func($inner_html); echo $test1 .\' \' . $test2 . \' \' . $html;
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

精彩评论

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