gpt4 book ai didi

php - PHP如何检查函数是否最后一次被调用

转载 作者:行者123 更新时间:2023-12-04 06:44:54 25 4
gpt4 key购买 nike

我想检查一个函数是否被最后一次调用。考虑以下示例代码,

function foo(){
if( this is the last call ) {
echo 'this is the last call of this function';
}
}

foo(); // should not print
foo(); // should not print
foo(); // since this is the last call, it should print

在我的项目中,我需要在函数中出现条件语句。

我有一个使用常量/全局变量/计数器的想法,但不知道如何实现。任何想法来检测函数的最后一次调用?

最佳答案

您是否尝试过使用 built-in shutdown function?

关于php - PHP如何检查函数是否最后一次被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3849914/

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