Skip to content

Commit

Permalink
Merge branch 'MDL-30966-print-object' of git://github.com/mudrd8mz/mo…
Browse files Browse the repository at this point in the history
…odle
  • Loading branch information
stronk7 committed Jan 8, 2012
2 parents df121fb + 68e550e commit 4b89edd
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/datalib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1957,19 +1957,26 @@ function count_login_failures($mode, $username, $lastlogin) {
/// GENERAL HELPFUL THINGS ///////////////////////////////////

/**
* Dump a given object's information in a PRE block.
* Dumps a given object's information for debugging purposes
*
* Mostly just used for debugging.
* When used in a CLI script, the object's information is written to the standard
* error output stream. When used in a web script, the object is dumped to a
* pre-formatted block with the "notifytiny" CSS class.
*
* @param mixed $object The data to be printed
* @return void OUtput is echo'd
* @return void output is echo'd
*/
function print_object($object) {
echo '<pre class="notifytiny">';

// we may need a lot of memory here
raise_memory_limit(MEMORY_EXTRA);
echo s(print_r($object, true));
echo '</pre>';

if (CLI_SCRIPT) {
fwrite(STDERR, print_r($object, true));
fwrite(STDERR, PHP_EOL);
} else {
echo html_writer::tag('pre', s(print_r($object, true)), array('class' => 'notifytiny'));
}
}

/**
Expand Down

0 comments on commit 4b89edd

Please sign in to comment.