<?php include 'debuglib.php'; # include debuglib at the first line in your script. Or load it through auto_prepend in your php.ini ?>
<?php DbugL::help(); ?>
print_a(mixed input [, string option_string])
The function you will use most often, prints a colorful representation of your PHP data
$option_string must be in the CSS like syntax:
e.g. "max_y:5;window:1;label:my_array"
If there is no ":" in the options string, the whole string will be used as the text for the label.
new
Valid options:
| return: | (0|1) | Do not print the output and instead return it as a string. |
| label: | (string) | Draw a fieldset/legend around the output. |
| max_y: | (1-n) | Maximum number of items on the same level. [...] (defaults to 50) |
| pickle: | (0|1) | Print a serialized representation of the array instead of printing it as a table. |
| export: | (0|1) | Print PHP sourcecode of the array. new |
| trim_tabs: | (0-n) | Trim the leading tabs in multiline strings and pad with n tabs. |
| window: | (string) | The output should open in a new window (javascript), the parameter is also the title for the window. |
| window_link: | (0|1) | Don't open a window, just print a link which opens one when clicked. new |
| debug_level: | (0-99) | Only do something if the debug level value is <= the global debug level ($GLOBALS['DEBUGLIB_LVL'] default 99) new |
| | You can also set it to an array with the levels you want to display e.g. $GLOBALS['DEBUGLIB_LVL'] = array(3,5) |
| avoid@: | (0|1) | If a key starts with the character "@", assume it is a recursive reference and don't follow it. |
| mail: | (string) | Mail the ouput as HTML mail to the supplied email address. new |
| mail_encoding: | (string) | encoding for the HTML mail. (defaults to "utf-8") |
show_vars([string option_string])
Prints all superglobals like $_GET, $_POST, $_SESSION etc. in a big table.
Good for printing at the bottom of a page.
Options are the same as for print_a + the following options:
verbose: also show $_SERVER and $_ENV
script_runtime([bool return_mode [, string title [, string css_style]]] )
Prints the passed time since the start of the script (or the last script_runtime call) in seconds.
pre(string string [, string option_string])
Print a string so the whitespaces are visible in HTML.
option_string must be in the CSS like syntax:
eg. "r:1;trim_tabs:0;"
Possible options:
| return: | (0|1) | return the output instead of printing it |
| trim_tabs: | (0-n) | same as in print_a() |
You can disable the output of all the functions in a production environment by setting
$GLOBALS['USE_DEBUGLIB'] to
FALSE (e.g. trough auto_prepend in your php.ini).
And if you have to do some online debugging you can enable it again somewhere in your script by setting it to
TRUE.
<?php script_runtime("START", "background:green;color:white;"); ?>
<?php print print_a($array, 'l:an array;r:1;tt:1'); ?>
<?php print_a(1); ?>
<?php print_a($object1, 'some object'); ?>
<?php print_a(' first <br />line '."\nsecond line", 'label:multiline string'); ?>
<?php print_a(array(1,2,3,4,5,6), 'w:window1;max_y:2;label:blam!;'); # opens in a new window ?>
<?php print print_a($array, 'return:1;w:window1;'); # opens in a new window ?>
<?php print_a($array[5], 'w:window1;label:decode this pickled array with unserialize();pickle:1;'); # opens in a new window ?>
<?php print_a($array[5], 'w:window1;label:and now the php sourcecode for the same array;export:1;'); # opens in a new window ?>
<?php print_a($array[3], 'w:window2;label:window_link demo;window_link:1'); # click to open in a new window ?>
<?php print_a(array('a', 'b', 'c'), 'w:window3;'); # opens in a new window ?>
<?php script_runtime("right after opening window3"); ?>
[right after opening window3] time: 0.529688 (0.508209 since last call)
<?php print_a($html); ?>
| (string) |
<div>
<span>
Chuck Norris does not sleep. He waits.
</span>
</div>
|
|---|
<?php pre($html); ?>
<div>
<span>
Chuck Norris does not sleep. He waits.
</span>
</div>
<?php pre($html, 'trim_tabs:0;'); ?>
<div>
<span>
Chuck Norris does not sleep. He waits.
</span>
</div>
<?php show_vars('trim_tabs:0;show_objects:0;max_y:5;'); ?>
[before show_vars] time: 0.530377 (0.000689 since last call)
Script $GLOBALS | html | <div>
<span>
Chuck Norris does not sleep. He waits.
</span>
</div> |
|---|
| array | | 1 | eins |
|---|
| 2 | zwei |
|---|
| 3 | | 0 | 11 |
|---|
| 1 | 1.2 |
|---|
| 2 | TRUE |
|---|
| 3 | FALSE |
|---|
| 4 | NULL |
|---|
| ... | [2 skipped] |
|---|
|
|---|
| 4 | vier |
|---|
| 5 | | band | | name | Rancid |
|---|
| members | | Vocals, Guitar | Tim Armstrong |
|---|
| Guitar, Vocals | Lars Frederiksen |
|---|
| Bass, Vocals | Matt Freeman |
|---|
| Drums | Brett Reed |
|---|
|
|---|
|
|---|
|
|---|
| ... | [3 skipped] |
|---|
|
|---|
| object | NULL |
|---|
| object1 | ... |
|---|
| object2 | ... |
|---|
|
$_SESSION | a session variable | |
|---|
| vars in the background | *eek* they see us! lets hide in the window name! |
|---|
|
[after show_vars] time: 0.533197 (0.002820 since last call)
<?php print script_runtime("-FIN-", "background:red;color:white;",1); ?>
[-FIN-] time: 0.533272 (0.000075 since last call)