Files
php_8/errors/set_error_handler.php
2022-05-25 21:00:08 +03:00

18 lines
749 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// Определяем новую функцию-обработчик
function myErrorHandler($errno, $msg, $file, $line)
{
echo '<div style="border-style:inset; border-width:2">';
echo "Произошла ошибка с кодом <b>$errno</b>!<br />";
echo "Файл: <tt>$file</tt>, строка $line.<br />";
echo "Текст ошибки: <i>$msg</i>";
echo '</div>';
}
// Регистрируем ее для всех типов ошибок
set_error_handler('myErrorHandler', E_ALL);
// Вызываем функцию для несуществующего файла, чтобы
// сгенерировать предупреждение, которое будет перехвачено
filemtime('spoon');