gpt4 book ai didi

php - 使用set_error_handler多次包含错误

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

为什么包含错误四次回显?

系统是否尝试4次“打开流”?

我做了:

function errorHandler($errno, $errstr, $errfile, $errline) {
if ($errno == E_NOTICE ) {
echo "<br/>".$errno."== E_NOTICE<br/>";
}
if ($errno == E_USER_NOTICE) {
echo "<br/>".$errno."== E_USER_NOTICE<br/>";
}
if ($errno == E_DEPRECATED) {
echo "<br/>".$errno."== E_DEPRECATED<br/>";
}
if ($errno == E_USER_DEPRECATED) {
echo "<br/>".$errno."== E_USER_DEPRECATED<br/>";
}
if ($errno == E_STRICT) {
echo "<br/>".$errno."== E_STRICT<br/>";
}
if ($errno == E_WARNING) {
echo "<br/>".$errno."== E_WARNING<br/>";
}
if ($errno == E_USER_WARNING) {
echo "<br/>".$errno."== E_USER_WARNING<br/>";
}
if ($errno == E_ERROR) {
echo "<br/>".$errno."== E_ERROR<br/>";
}
if ($errno == E_USER_ERROR) {
echo "<br/>".$errno."== E_USER_ERROR<br/>";
}
}
set_error_handler("errorHandler");

结果:
2== E_WARNING

2== E_WARNING

2== E_WARNING

2== E_WARNING

最佳答案

没有看到与您的错误有关的其他信息,很难说。

Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, include will finally check in the calling script's own directory and the current working directory before failing. The include construct will emit a warning if it cannot find a file; this is different behavior from require, which will emit a fatal error.



include()的文件化。

PHP considers each entry in the include path separately when looking for files to include. It will check the first path, and if it doesn't find it, check the next path, until it either locates the included file or returns with a warning or an error. You may modify or set your include path at runtime using set_include_path().



在包含过程中按照PHP docs进行操作。

附带说明一下,我对您提供的自定义 errorHandler()函数进行了一些修改。
<?php
function errorHandler($errno, $errstr, $errfile, $errline) {
$response;

switch ($errno){
case E_NOTICE:
$reponse = 'E_NOTICE';
break;

case E_USER_NOTICE:
$reponse = 'E_USER_NOTICE';
break;

case E_DEPRECATED:
$reponse = 'E_DEPRECATED';
break;

case E_USER_DEPRECATED:
$reponse = 'E_USER_DEPRECATED';
break;

case E_STRICT:
$reponse = 'E_STRICT';
break;

case E_WARNING:
$reponse = 'E_WARNING';
break;

case E_USER_WARNING:
$reponse = 'E_USER_WARNING';
break;

case E_ERROR:
$reponse = 'E_ERROR';
break;

case E_USER_ERROR:
$reponse = 'E_USER_ERROR';
break;
}
echo "<br />Errno: [$errno]; Type: [$reponse]<br />";
echo "<br />Error on line [$errline] in file [$errfile]<br />";
echo "<br />Error: ". $errstr . "<br />";
}

set_error_handler("errorHandler");

?>

关于php - 使用set_error_handler多次包含错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11319137/

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