PHP: Suppress output within a function?

后端 未结 4 2019
[愿得一人]
[愿得一人] 2020-12-08 19:28

What is the simplest way to suppress any output a function might produce? Say I have this:

function testFunc() {
    echo \'Testing\';
    return true;
}
         


        
4条回答
  •  被撕碎了的回忆
    2020-12-08 19:44

    Here you go:

    ob_start();
    testFunc();
    ob_end_clean();
    

    "ob" stands for "output buffering", take a look at the manual pages here: http://www.php.net/outcontrol

提交回复
热议问题