php8.5
Home/ Manual/ predefined / variables/ $php_errormsg

$php_errormsg

PHP function Edit on GitHub ✎

The previous error message

Removed-8-0-0 Use error_get_last() instead.

Description

$php_errormsg is a variable containing the text of the last error message generated by PHP. This variable will only be available within the scope in which the error occurred, and only if the track_errors configuration option is turned on (it defaults to off).

Warning

If a user defined error handler (set_error_handler()) is set $php_errormsg is only set if the error handler returns false.

Changelog

VersionDescription
8.0.0Directive track_errors which caused $php_errormsg to be available has been removed.
7.2.0Directive track_errors which caused $php_errormsg to be available has been deprecated.

Examples

$php_errormsg example

php
<?php
@strpos();
echo $php_errormsg;
?>

The above example will output something similar to:

output
Wrong parameter count for strpos()

See Also

Source: language/predefined/variables/phperrormsg.xml · from the official PHP manual (php/doc-en)