I am attempting to do a var_dump from a controller to my log file and I’m left with an empty line.
Here’s the code within my controller:
$checked = 'test error';
log_message('error', var_dump($checked));
In my log file, I get:
ERROR - 2014-06-23 12:30:34->
I am able to get the result of:
$checked = 'test error';
log_message('error', $checked);
So, it must be an issue with var_dump()?
Any ideas? Thanks for the help.
The var_dump() function dumps information about one or more variables. The information holds type and value of the variable(s).
var_dump() displays values along with data types as output. print_r() displays only value as output. It does not have any return type. It will return a value that is in string format.
Based on PHP var_dump()
documentation, var_dump()
LINK doesn't return, it only outputs.
Therefore you can use output buffering PHP function like the following:
<?php
ob_start();
var_dump($data);
$result = ob_get_contents(); //or ob_get_clean()
//ob_end_clean()
?>
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