How to use
Create an instance of the dBug class and pass in the variable for output.
1
2
include_once("dBug.php");
new dBug($myVariable);
That simple. No need to access specific methods in the class.
NOTE: It's advisable to create a new instance of the dBug class each time you need to dump a variable.
This ensures that all the public class variables are reset. This is really helpful especially when
you are trying to dump xml variables.
1
2
new dBug($myVariable1);
new dBug($myVariable2);
String
1
2
$variable = "this is my string";
new dBug($variable);
Output:
Array
1
2
3
4
5
6
7
8
9
$variable = array(
"first"=>"1",
"second",
"third"=>array(
"inner third 1",
"inner third 2"=>"yeah"),
"fourth");
new dBug($variable);
Output:
| first |
1 |
| 0 |
second |
| third |
| 0 |
inner third 1 |
| inner third 2 |
yeah |
|
| 1 |
fourth |
Object
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Vegetable {
var $edible;
var $color;
function Vegetable($edible, $color="green") {
$this->edible = $edible;
$this->color = $color;
}
function is_edible() {
return $this->edible;
}
function what_color() {
return $this->color;
}
}
$variable=new Vegetable("spinach");
new dBug($variable);
Output:
| edible |
spinach |
| color |
green |
| vegetable |
[function] |
| is_edible |
[function] |
| what_color |
[function] |
Database resource
When a database resource is dumped, mouse-overing the column names (example: ID, firstname,...) will display
the database column type information in alt tags.
1
2
3
4
5
6
7
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link)
die('Could not connect: ' . mysql_error());
mysql_select_db('mydb');
$result = mysql_query('select * from empinfo');
new dBug($result);
Output:
| | ID | firstname | lastname | age | city | state |
| 1 | 99980 |
John |
Jones |
45 |
Payson |
Arizona |
| 2 | 99982 |
Mary |
Jones |
25 |
Payson |
Arizona |
| 3 | 88232 |
Eric |
Howell |
32 |
San Diego |
California |
| 4 | 88233 |
Mary Ann |
Edwards |
32 |
Phoenix |
Arizona |
|
XML Resource
When an xml variable is dumped as is, it is recognized as a string. This is even so with PHP's var_dump. The dBug class has a second optional parameter
where you pass in the string "xml".
1
2
$xmlData = "msc/data.xml"; //path to xml file;
new dBug($xmlData, "xml");
Output:
| xmlRoot |
| xmlName |
chapter |
| xmlAttributes |
|
| xmlText |
|
| xmlComment |
|
| xmlChildren |
| xmlName |
TITLE |
| xmlAttributes |
|
| xmlText |
This is my title |
| xmlComment |
|
| xmlChildren |
|
| xmlName |
tgroup |
| xmlAttributes |
|
| xmlText |
|
| xmlComment |
Another comment here
on second line |
| xmlChildren |
| xmlName |
entry |
| xmlAttributes |
|
| xmlText |
b1 |
| xmlComment |
|
| xmlChildren |
|
|
|
|