简体   繁体   中英

ob_start(); callback function

Is there any difference (performance or otherwise) to use ob_start in the following ways?

Option 1:

function ob_handle($buffer){/*do something, and return buffer*/}
ob_start('ob_handle');

Option 2:

ob_start(function($buffer){/*do something, and return buffer*/});

Thanks!

There's hardly a difference performance-wise. It's just a matter of how the callback function is declared, it doesn't change anything about how the function is used or executed. If you want to know for sure, benchmark it .

The only difference is that in the first case you're declaring a global function ob_handle , which you can use again from elsewhere and which takes up the global name ob_handle . In the second case, you cannot refer to the anonymous function from elsewhere again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM