Changeset 464 for trunk/lib/Utilities.inc.php
- Timestamp:
- Feb 8, 2014 2:29:30 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Utilities.inc.php
r457 r464 33 33 * @param bool $var_dump Use var_dump instead of print_r. 34 34 */ 35 function dump($var, $display=false, $var_dump=false )35 function dump($var, $display=false, $var_dump=false, $file, $line) 36 36 { 37 37 if (defined('_CLI')) { … … 52 52 } 53 53 54 /** 55 * Return dump as variable. 56 * 57 * @param mixed $var Variable to dump. 58 * @param bool $serialize Remove line-endings. Useful for logging variables. 59 * @return string Dump of var. 60 */ 54 /* 55 * Log a PHP variable to javascript console. Relies on getDump(), below. 56 * 57 * @access public 58 * @param mixed $var The variable to dump. 59 * @param string $prefix A short note to print before the output to make identifying output easier. 60 * @param string $file The value of __FILE__. 61 * @param string $line The value of __LINE__. 62 * @return null 63 * @author Quinn Comendant <quinn@strangecode.com> 64 */ 65 function jsDump($var, $prefix='jsDump', $file='-', $line='-') 66 { 67 if (!empty($var)) { 68 ?> 69 <script type="text/javascript" charset="utf-8"> 70 /* <![CDATA[ */ 71 window.console && console.log('<?php printf('%s: %s (on line %s of %s)', $prefix, str_replace("'", "\\'", getDump($var, true)), $line, $file); ?>'); 72 /* ]]> */ 73 </script> 74 <?php 75 } 76 } 77 78 /* 79 * Return a string version of any variable, optionally serialized on one line. 80 * 81 * @access public 82 * @param mixed $var The variable to dump. 83 * @param bool $serialize If true, remove line-endings. Useful for logging variables. 84 * @return string The dumped variable. 85 * @author Quinn Comendant <quinn@strangecode.com> 86 */ 61 87 function getDump($var, $serialize=false) 62 88 {
Note: See TracChangeset
for help on using the changeset viewer.