diff --git a/lib/datalib.php b/lib/datalib.php index a41945b4ce7..91d97bd9463 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -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 '
';
+
     // we may need a lot of memory here
     raise_memory_limit(MEMORY_EXTRA);
-    echo s(print_r($object, true));
-    echo '
'; + + 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')); + } } /**