Like var_dump from CodeIgniter controller

I am trying to do var_dump from the controller to my log file, and Im left an empty line.

Here is the code inside 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 can get the result:

$checked = 'test error';
log_message('error', $checked);

So this should be the problem with var_dump ()?

Any ideas? Thanks for the help.

+4
source share
2 answers

Based on the PHP documentation, var_dump() var_dump() LINK is not returned; it is only output.

Therefore, you can use output buffering. The PHP function is as follows:

<?php
   ob_start();
   var_dump($data);
   $result = ob_get_contents(); //or ob_get_clean()
   //ob_end_clean() 
?>
+2
source

var_export ($ variable, true) , . , echo . , var_dump. , , ... .

+2

Source: https://habr.com/ru/post/1545733/


All Articles