gpt4 book ai didi

php - 我如何检查我的功能打印/echo 是否有什么?

转载 作者:IT王子 更新时间:2023-10-28 23:49:05 25 4
gpt4 key购买 nike

我经常使用 echo 来调试函数代码:

public function MyFunc() {

// some code...
echo "OK";
// some code...

}

我如何检查我的函数 print/echo 是什么东西?

(伪代码):

MyFunc();

if (<when something was printed>){
echo "You forgot to delete echo calls in this function";
}

最佳答案

这应该适合你:

只要调用你的函数,而你有 output buffering打开并检查内容是否为空,例如

ob_start();

//function calls here
MyFunc();

$content = ob_get_contents();

ob_end_clean();

if(!empty($content))
echo "You forgot to delete echos for this function";

关于php - 我如何检查我的功能打印/echo 是否有什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31337464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com