PHP: Suppress output within a function?

后端 未结 4 2017
[愿得一人]
[愿得一人] 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:40

    Yes you are on the right track as to leveraging PHP's output buffering functions, i.e. ob_start and ob_end_clean (look them up on php.net):

    
    

提交回复
热议问题