PHP.nl

trigger_error

trigger_error

Generates a user-level error/warning/notice message

true **trigger_error** string $message int $error_level

Used to trigger a user error condition, it can be used in conjunction with the built-in error handler, or with a user defined function that has been set as the new error handler (). set_error_handler

This function is useful when you need to generate a particular response to an exception at runtime.

messageThe designated error message for this error. It's limited to 1024 bytes in length. Any additional characters beyond 1024 bytes will be truncated.

error_level The designated error type for this error. It only works with the family of constants, and will default to . E_USER_*``E_USER_NOTICE

Waarschuwing: > Passing as the is now deprecated. Throw an or call instead. E_USER_ERROR``error_level``exit

return.true.always

This function throws a if is not one of , , , . ValueError``error_level``E_USER_ERROR``E_USER_WARNING``E_USER_NOTICE``E_USER_DEPRECATED

Voorbeeld: example

 See  for a more extensive example.
`set_error_handler`
<?php
$password = $_POST['password'] ?? '';
if ($password === '') {
  trigger_error("Using an empty password is unsafe", E_USER_WARNING);
}
$hash = password_hash($password, PASSWORD_DEFAULT);
?>

Waarschuwing: > HTML entities in are not escaped. Use on the message if the error is to be displayed in a browser. message``htmlentities

error_reporting``set_error_handler``restore_error_handlererror level constantsDeprecated