How to print or save internal detail of an object?

Re: How to print or save internal detail of an object?

by wz z -
Number of replies: 2

I tried print_r($var, true), it works. But unfortunately, Apache errolog truncated the $eventdata variable, I cannot view all its internal detail. 

Could you tell me the exact exit command in Moodle, please?

In reply to wz z

Re: How to print or save internal detail of an object?

by Conn Warwicker -
Picture of Core developers Picture of Plugin developers

It might be easier to just log the contents to a different file.


You can write a simple function for that, e.g.




function mylog($value)

{

    global $CFG;

    $file = fopen($CFG->dataroot . '/myfile.txt', 'a');

    if ($file){

        fwrite($file, print_r($value, true));

        fwrite($file, "\n");

        fclose($file);

    }

}


Then just call it with: mylog($eventdata)





In reply to Conn Warwicker

Re: How to print or save internal detail of an object?

by wz z -

Thank you, it works!