Not able to print variable in log file

Hello All,

I want to sort the report dropdown of Generic Dashlet : Options

I want to print $ZZZZf5 varibale in log with the help of $GLOBALS[‘log’]->fatal(print($ZZZZf5)); file but I am unable to get any result in log file, kindly assist.

Thanks in advance

Remove the print call, leave just the variable name

Hi @pgr thanks for reply

     $GLOBALS['log']->fatal($ZZZZf5); i used this also but nothing is coming

Sorry, my bad. You do need some way to echo out the variable, it’s just that print is not even a function call, it’s a statement in PHP.

Here are some examples:

$GLOBALS['log']->fatal("Using string interpolation with double-quotes: $oneValue, $anotherValue");
$GLOBALS['log']->fatal('With complex values such as arrays: ' . print_r($row, true));

Use the print_r function instead of print function & pass the TRUE argument in the print_r function.
Ex: $GLOBALS[‘log’]->fatal(print_r($ZZZZf5, TRUE));

Thanks @pgr

I tried both but I am not getting any result

$GLOBALS[‘log’]->fatal(“Using string interpolation with double-quotes: $ZZZZf5, $ZZZZf5”);

    $GLOBALS['log']->fatal(print_r($ZZZZf5, TRUE));

    $GLOBALS['log']->fatal('With complex values such as arrays: ' . print_r($ZZZZf5, true));

I tried like this

What if you just write a fixed string, without any variables, do you see it in the log?

If you have a PHP syntax error, it will show in the other log, php_errors.log

You should always check both those logs.

What if you just write a fixed string, without any variables, do you see it in the log?

  • Yes I can see

I checked in PHP error log too but there is nothing

Then I guess it’s just your variable, probably empty or null.