gpt4 book ai didi

php - register_shutdown_function() 不调用我的函数

转载 作者:行者123 更新时间:2023-12-03 08:00:26 26 4
gpt4 key购买 nike

当脚本出现 fatal error 时,我做了一个自定义重定向功能:

这在所有页面之前包含的前置脚本上调用:

register_shutdown_function("shutdownHandler");
function shutdownHandler()
{
$lasterror = error_get_last();
switch ($lasterror['type'])
{
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_PARSE:
$error = "[SHUTDOWN] lvl:" . $lasterror['type'] . " | msg:" . $lasterror['message'] . " | file:" . $lasterror['file'] . " | ln:" . $lasterror['line'];
writeError($error, "fatal");
header("location:maintenance.php");
}
}

但是没有调用该函数,有什么想法吗?

最佳答案

我解决了这个问题!

通过在指令下的 php.ini 文件中添加我的 errorsHandler.php 脚本:

自动前置文件 = [路径/到/文件]

希望它会有所帮助;)

关于php - register_shutdown_function() 不调用我的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21862823/

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