1.2.4. $php_errormsg Usage

$php_errormsg is removed since PHP 8.0. $php_errormsg tracks the last error message, with the directive track_errors. All was removed in PHP 8.0, and shall be replaced with error_get_last().

<?php

function foo() {
    global $php_errormsg;

    echo 'Last error: '.$php_errormsg;

    echo 'Also, last error: '.error_get_last();
}

?>

1.2.4.1. Suggestions

  • Use error_get_last() instead.

1.2.4.2. Specs

Short name

Php/PhpErrorMsgUsage

Rulesets

All, CE, Changed Behavior, CompatibilityPHP80

Exakat since

2.1.8

PHP Version

With PHP 8.0 and older

Severity

Minor

Time To Fix

Quick (30 mins)

Changed Behavior

PHP 8.0 - More

Precision

High

Features

$php_errormsg

Available in

Entreprise Edition, Community Edition, Exakat Cloud