log_error
Описание
Создает запись в лог файл, если ведение лога разрешено.
Синтаксис
string log_error (string $error_message[, string $error_type[, mixed $file[, mixed $line]]])
$error_message
Expected type: String
Description: Текст сообщения об ошибке
$error_type
Expected type: Enumerated String
Описание: Тип ошибки (используется для фильтрации в журнале ошибок)
'critical' Критическая ошибка
'database' Ошибка, связанная с базой данных
'general' Общая ошибка (значение по умолчанию)
'template' Ошибка шаблона, например ошибка синтаксического анализа
'undefined_vars' Ошибка связана с обнаружением неопределенных данных
'user' Ошибки, характерные для пользователя, например "неверный пароль"
$file
Expected type: Mixed
Description: Файл, в котором произошла эта ошибка (либо null, либо имя файла)
Allowed types for $file
Allowed values Description
Null Default value
String The full path to the file
$line
Expected type: Mixed
Description: The line number where this error occurred
Allowed types for $line
Allowed values Description
Null Default value
Integer The line number where the error occurred
Возвращаемое значение
Expected type: String
Description: Returns the error message with additional information about the file and line number.
Замечание
Зависит от настройки enableErrorLogging.
Имя файла и строка должны быть __FILE__ и __LINE__ соответственно.
Возвращает сообщение об ошибке. (т. е. die(log_error($msg));)
1. технарь - 23 августа 2024 — 16:58 - перейти к сообщению
2. технарь - 23 августа 2024 — 17:17 - перейти к сообщению
setup_fatal_error_context
Description
Sets up the $context stuff for a fatal error
Syntax
void setup_fatal_error_context (string $error_message)
Parameter $error_message
Expected type: String
Description: The specific error message (only used if $context['error_message'] isn't already set)
Notes
Just sets up the $context stuff for fatal errors
Loads the appropriate sub-template (either 'fatal_error' or the appropriate template for the wireless protocol)
If we're using SSI.php, determines what to do based on $ssi_on_error_method (if it's true, the function just exits; if it's not true and is a function, it calls that function; otherwise it just loads the fatal_error sub-template)
Description
Sets up the $context stuff for a fatal error
Syntax
void setup_fatal_error_context (string $error_message)
Parameter $error_message
Expected type: String
Description: The specific error message (only used if $context['error_message'] isn't already set)
Notes
Just sets up the $context stuff for fatal errors
Loads the appropriate sub-template (either 'fatal_error' or the appropriate template for the wireless protocol)
If we're using SSI.php, determines what to do based on $ssi_on_error_method (if it's true, the function just exits; if it's not true and is a function, it calls that function; otherwise it just loads the fatal_error sub-template)
3. технарь - 23 августа 2024 — 17:18 - перейти к сообщению
fatal_lang_error
Описание
Останавливает выполнение и выводит сообщение об ошибке в соответствии с указанным ключом.
Синтаксис
void fatal_lang_error (string $error[, mixed $log[, array $sprintf]])
$error
Ожидаемый тип: String
Описание: The key for the language string to be used as the error message
$log
Ожидаемый тип: Mixed
Описание: Регистрировать ли ошибку в журнале, и если да, то какой это тип ошибки
Allowed types for $log
Allowed values Description
Boolean false if you don't want to log the error
Enumerated String The type of error this is (see log_error) - defaults to 'general'
$sprintf
Ожидаемый тип: Array
Описание: Информация, которая должна быть вставлена в строку с помощью vsprintf() (для получения дополнительной информации см. http://www.php.net/sprintf) — по умолчанию пустой массив
Замечание
$error — ключ массива $txt, соответствующий сообщению об ошибке, которое мы хотим отобразить
Загружает языковой файл Errors.
Применяет информацию sprintf, если она указана.
Информация регистрируется, если log имеет значение true или отсутствует.
Использует шаблон Errors с подшаблоном fatal_error или соответствующий подшаблон error в шаблоне Wirless.
Пример
fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings');
Описание
Останавливает выполнение и выводит сообщение об ошибке в соответствии с указанным ключом.
Синтаксис
void fatal_lang_error (string $error[, mixed $log[, array $sprintf]])
$error
Ожидаемый тип: String
Описание: The key for the language string to be used as the error message
$log
Ожидаемый тип: Mixed
Описание: Регистрировать ли ошибку в журнале, и если да, то какой это тип ошибки
Allowed types for $log
Allowed values Description
Boolean false if you don't want to log the error
Enumerated String The type of error this is (see log_error) - defaults to 'general'
$sprintf
Ожидаемый тип: Array
Описание: Информация, которая должна быть вставлена в строку с помощью vsprintf() (для получения дополнительной информации см. http://www.php.net/sprintf) — по умолчанию пустой массив
Замечание
$error — ключ массива $txt, соответствующий сообщению об ошибке, которое мы хотим отобразить
Загружает языковой файл Errors.
Применяет информацию sprintf, если она указана.
Информация регистрируется, если log имеет значение true или отсутствует.
Использует шаблон Errors с подшаблоном fatal_error или соответствующий подшаблон error в шаблоне Wirless.
Пример
fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings');
4. технарь - 23 августа 2024 — 17:19 - перейти к сообщению
fatal_error
Description
Stops execution and displays an error message.
Syntax
void fatal_error (string $error[, mixed $log])
Parameter $error
Expected type: String
Description: The error message
Parameter $log
Expected type: Mixed
Description: Whether or not to log the error, and if so, what type of error this is
Allowed types for $log
Allowed values Description
Boolean false, if you don't want the error to be logged
Enumerated String What type of error this is (see log_error) - defaults to 'general'
Notes
$log specifies what type of error this is (or 'false' if the error shouldn't be logged)
If $log isn't set, the error will be logged as a 'general' error (see log_error)
Description
Stops execution and displays an error message.
Syntax
void fatal_error (string $error[, mixed $log])
Parameter $error
Expected type: String
Description: The error message
Parameter $log
Expected type: Mixed
Description: Whether or not to log the error, and if so, what type of error this is
Allowed types for $log
Allowed values Description
Boolean false, if you don't want the error to be logged
Enumerated String What type of error this is (see log_error) - defaults to 'general'
Notes
$log specifies what type of error this is (or 'false' if the error shouldn't be logged)
If $log isn't set, the error will be logged as a 'general' error (see log_error)
5. технарь - 23 августа 2024 — 17:20 - перейти к сообщению
error_handler
Description
A standard replacement for PHP's error handler.
Syntax
void error_handler (int $error_level, string $error_string, string $file, int $line)
Parameter $error_level
Expected type: Integer
Description: Determines the level of this error (see http://www.php.net/error_reporting)
Parameter $error_string
Expected type: String
Description: The error message
Parameter $file
Expected type: String
Description: The file where this error was generated
Parameter $line
Expected type: Integer
Description: The line number where this error occurred
Notes
Dies with fatal_error if the error level matches ERROR_REPORTING (see PHP manual)
Description
A standard replacement for PHP's error handler.
Syntax
void error_handler (int $error_level, string $error_string, string $file, int $line)
Parameter $error_level
Expected type: Integer
Description: Determines the level of this error (see http://www.php.net/error_reporting)
Parameter $error_string
Expected type: String
Description: The error message
Parameter $file
Expected type: String
Description: The file where this error was generated
Parameter $line
Expected type: Integer
Description: The line number where this error occurred
Notes
Dies with fatal_error if the error level matches ERROR_REPORTING (see PHP manual)
6. технарь - 23 августа 2024 — 17:21 - перейти к сообщению
db_fatal_error
Description
Loads Subs-Auth.php and calls show_db_error().
Syntax
bool db_fatal_error ([bool $loadavg])
Parameter $loadavg
Expected type: Boolean
Description: Whether or not this is a load-average problem. Defaults to false.
Return value
Expected type: Boolean
Description: Returns false (because of "Or db_fatal_error()"...)
Notes
This is used for database connection error handling.
Loadavg means this is a load average problem, not a database error.
Description
Loads Subs-Auth.php and calls show_db_error().
Syntax
bool db_fatal_error ([bool $loadavg])
Parameter $loadavg
Expected type: Boolean
Description: Whether or not this is a load-average problem. Defaults to false.
Return value
Expected type: Boolean
Description: Returns false (because of "Or db_fatal_error()"...)
Notes
This is used for database connection error handling.
Loadavg means this is a load average problem, not a database error.
7. технарь - 24 августа 2024 — 07:08 - перейти к сообщению
trigger_error
Стандартная функция PHP
Вызывает пользовательскую ошибку/предупреждение/уведомление
Описание
bool trigger_error ( string $error_msg [, int $error_type = E_USER_NOTICE ] )
Используется для вызова пользовательских ошибок, можно использовать в связке с встроенным обработчиком ошибок, а также с пользовательским обработчиком, заданным функцией set_error_handler().
Эта функция может быть полезной, если требуется сгенерировать определенную реакцию на исключение во время выполнения.
Список параметров
error_msg
Сообщение, соответствующее этой ошибке. Ограничено 1024 байтами в длину. Символы дальше 1024-го будут обрезаны.
error_type
Назначенный тип ошибки. Работает только с семейством констант E_USER. По умолчанию E_USER_NOTICE.
Возвращаемые значения
Функция возвращает FALSE, если задан неправильный error_type, и TRUE в остальных случаях.
Примеры
Пример #1 Пример использования trigger_error()
Более подробный пример приведен в описании функции set_error_handler().
<?php
if ($divisor == 0) {
trigger_error("Не могу поделить на ноль", E_USER_ERROR);
}
?>
trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR);
Примечания
Внимание
HTML сущности в error_msg не экранированы. чтобы сообщение можно было отобразить в броузере, преобразуйте его функцией htmlentities().
Стандартная функция PHP
Вызывает пользовательскую ошибку/предупреждение/уведомление
Описание
bool trigger_error ( string $error_msg [, int $error_type = E_USER_NOTICE ] )
Используется для вызова пользовательских ошибок, можно использовать в связке с встроенным обработчиком ошибок, а также с пользовательским обработчиком, заданным функцией set_error_handler().
Эта функция может быть полезной, если требуется сгенерировать определенную реакцию на исключение во время выполнения.
Список параметров
error_msg
Сообщение, соответствующее этой ошибке. Ограничено 1024 байтами в длину. Символы дальше 1024-го будут обрезаны.
error_type
Назначенный тип ошибки. Работает только с семейством констант E_USER. По умолчанию E_USER_NOTICE.
Возвращаемые значения
Функция возвращает FALSE, если задан неправильный error_type, и TRUE в остальных случаях.
Примеры
Пример #1 Пример использования trigger_error()
Более подробный пример приведен в описании функции set_error_handler().
<?php
if ($divisor == 0) {
trigger_error("Не могу поделить на ноль", E_USER_ERROR);
}
?>
trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR);
Примечания
Внимание
HTML сущности в error_msg не экранированы. чтобы сообщение можно было отобразить в броузере, преобразуйте его функцией htmlentities().