I have this code :
<?php
define('LOG_DEBUG','DEBUG');
define('LOG_ERROR','ERROR');
function trace($message,$level=LOG_DEBUG){
echo '['.date('Y-m-d H:i:s').' '.$level.'] '.$message."\n";
}
trace('test debug message');
trace('test error message', LOG_ERROR);
Output (Running in PHP 7.4) :
PHP Notice: Constant LOG_DEBUG already defined in /var/www/mail_dumper/PHPMailDumper.php on line 3
[2022-02-11 22:00:33 7] test debug message
[2022-02-11 22:00:33 ERROR] test error message
I don't understand the notice...
I tried to affect LOG_DEBUG to default value and not try to reaffect?
And... In trace test we see a "7" in output?
CodePudding user response:
You're getting this warning because LOG_DEBUG
is a predefined PHP constant for the syslog
function.