I want to do something like:
error_log('this is information about the variable: '.print_r($variable));
or
error_log('this is information about the variable: '.var_dump($variable));
FYI, the variable I'm trying to print is an array.
print_r() accepts a second parameter which will return its output as a string. As such, your first example can be modified to the following:
error_log('this is information about the variable: ' . print_r($variable, true));
Note: While var_dump() does not have such a parameter, you could use output buffering to store its output as described in the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With