【发布时间】:2016-05-05 04:06:37
【问题描述】:
我收到此错误:
set_error_handler() 期望参数 (userErrorAdvice) 是一个有效的回调
trait userErrorAdviceTrait
{
public function userErrorAdvice()
{
$error = error_get_last();
$_SESSION['errorStore'] = $error;
$errorMessage = "No file exists for the PageController";
if (strstr($error['message'], "No file exists for the PageController class"))
{
header('Location: http://192.171.127.39/~louis/errorAdvicePage.php?errorType=NoPageControllerError');
exit;
}
}
public function setUserErrorAdvice()
{
set_error_handler("userErrorAdvice");
}
}
use userErrorAdviceTrait;
public static function makePageController($pageName)
{
//self::shutDownFunction();
//self::shutdown_function();
self::setUserErrorAdvice();
//Rest of code ....
这迫使我写更多细节,但我无话可说。
【问题讨论】:
-
对此不是 100% 确定,但我猜这是范围问题。
set_error_handler不仅适用于特定类,还适用于整个脚本,因此它正在寻找一个名为userErrorAdvice()的全局函数。因为它没有发现它会引发该错误。 -
http://192.171.127./~louis[etc]看起来不是一个有效的 URL。 -
nvm 的 url,这只是我在 stackoveflow 上输入的错误。会调整的。
-
@Flaco_Taco 关于您上次的编辑,不,这不是“强迫”您添加任何细节。如果这个问题感觉很空洞,那是因为它是。不要加绒毛来加绒毛,这也是我一开始去掉它的原因。
标签: php error-handling callback