PHP Tutorial PHP Advanced PHP References

PHP $php_errormsg Variable

The PHP $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).

The use of error_get_last() function is recommended.

Note: This feature has been DEPRECATED as of PHP 7.2.0.

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

Example: $php_errormsg example

The example below demonstrates the usage of $php_errormsg variable.

echo $php_errormsg;

The output of the above script will be similar to:

Wrong parameter count for strpos()

❮ PHP - Predefined Variables