Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'MDL-30966-print-object_21_STABLE' of git://github.com/m…

…udrd8mz/moodle into MOODLE_21_STABLE
  • Loading branch information...
commit 86e84df668880975fcca872b2f8e3a23941b6ada 2 parents d811195 + f711613
Eloy Lafuente (stronk7) authored January 09, 2012

Showing 1 changed file with 13 additions and 6 deletions. Show diff stats Hide diff stats

  1. 19  lib/datalib.php
19  lib/datalib.php
@@ -1929,19 +1929,26 @@ function count_login_failures($mode, $username, $lastlogin) {
1929 1929
 /// GENERAL HELPFUL THINGS  ///////////////////////////////////
1930 1930
 
1931 1931
 /**
1932  
- * Dump a given object's information in a PRE block.
  1932
+ * Dumps a given object's information for debugging purposes
1933 1933
  *
1934  
- * Mostly just used for debugging.
  1934
+ * When used in a CLI script, the object's information is written to the standard
  1935
+ * error output stream. When used in a web script, the object is dumped to a
  1936
+ * pre-formatted block with the "notifytiny" CSS class.
1935 1937
  *
1936 1938
  * @param mixed $object The data to be printed
1937  
- * @return void OUtput is echo'd
  1939
+ * @return void output is echo'd
1938 1940
  */
1939 1941
 function print_object($object) {
1940  
-    echo '<pre class="notifytiny">';
  1942
+
1941 1943
     // we may need a lot of memory here
1942 1944
     raise_memory_limit(MEMORY_EXTRA);
1943  
-    echo s(print_r($object, true));
1944  
-    echo '</pre>';
  1945
+
  1946
+    if (CLI_SCRIPT) {
  1947
+        fwrite(STDERR, print_r($object, true));
  1948
+        fwrite(STDERR, PHP_EOL);
  1949
+    } else {
  1950
+        echo html_writer::tag('pre', s(print_r($object, true)), array('class' => 'notifytiny'));
  1951
+    }
1945 1952
 }
1946 1953
 
1947 1954
 /**

0 notes on commit 86e84df

Please sign in to comment.
Something went wrong with that request. Please try again.