General developer forum

How to print or save internal detail of an object?

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

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?

 
Average of ratings: -
Picture of Conn Warwicker
Re: How to print or save internal detail of an object?
Core developersParticularly helpful MoodlersPlugin 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)





 
Average of ratings: -