error_log() output for print_r() appearing on page

The print_r function accept second parameter for return so it retrun the variable instead of printing it.

print_r($expression, $return)

So you can do

error_log( print_r( $variable, true ) );

Leave a Comment