1

i have this error in my coding Deprecated: Required parameter $message follows optional parameter $level in C:\xampp\htdocs\praktik_1855201019-rest\system\core\Common.php on line 351 .

this is line 349-363 looks like

if ( ! function_exists('log_message'))
{
    function log_message($level = 'error', $message, $php_error = FALSE) **(this one line 351)**
    {
        static $_log;

        if (config_item('log_threshold') == 0)
        {
            return;
        }

        $_log =& load_class('Log');
        $_log->write_log($level, $message, $php_error);
    }
}

if anyone can help, please leave an answer for my error. thank you so much

IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • I think it's simply because when you create a function with optional parameters then they have to be put after the mandatory parameters. Here `$message` is mandatory and it is put after `$level` which is optional as it has a default value set to `'error'`. – Patrick Janser Dec 13 '21 at 17:36
  • 1
    That is the first item noted on the [PHP 8 deprecation page](https://www.php.net/manual/en/migration80.deprecated.php). You can either change the order of the parameters, so that `$message` comes first, or you can give `$message` a default value. – Chris Haas Dec 13 '21 at 17:42
  • it's working! thank you so much – 019_Alya Haryanti Dec 14 '21 at 06:48

0 Answers0