, ; , ... , , : - (
, , , , , :
, , , - : -, :
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
$str = '';
switch ($errno) {
case E_USER_ERROR:
$str .= "<b>My ERROR</b> [$errno] $errstr<br />\n";
$str .= " Fatal error on line $errline in file $errfile";
$str .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
break;
case E_USER_WARNING:
$str .= "<b>My WARNING</b> [$errno] $errstr<br />\n";
break;
case E_USER_NOTICE:
$str .= "<b>My NOTICE</b> [$errno] $errstr<br />\n";
break;
default:
$str .= "Unknown error type: [$errno] $errstr<br />\n";
break;
}
$str .= print_r($_GET, true);
$str .= "\n";
file_put_contents(dirname(__FILE__) . '/log.txt', $str, FILE_APPEND);
/* Don't execute PHP internal error handler */
return true;
}
, , , $_GET .
(, - / )
:
$old_error_handler = set_error_handler("myErrorHandler");
, , :
trigger_error("test of E_USER_ERROR", E_USER_ERROR);
trigger_error("test of E_USER_WARNING", E_USER_WARNING);
trigger_error("test of E_USER_NOTICE", E_USER_NOTICE);
, - : http://tests/temp/temp.php?a=10&test=glop&hello=world; , :
$ cat log.txt
<b>My ERROR</b> [256] test of E_USER_ERROR<br />
Fatal error on line 34 in file /home/squale/developpement/tests/temp/temp.php, PHP 5.3.0RC4 (Linux)<br />
Array
(
[a] => 10
[test] => glop
[hello] => world
)
<b>My WARNING</b> [512] test of E_USER_WARNING<br />
Array
(
[a] => 10
[test] => glop
[hello] => world
)
<b>My NOTICE</b> [1024] test of E_USER_NOTICE<br />
Array
(
[a] => 10
[test] => glop
[hello] => world
)
... , , ; , , , , ; -)
, (, , ...); , , : - (
, , , ...
( , - , ? , , ;-) , , , ))
, !