PHP_Debug
[ class tree: PHP_Debug ] [ index: PHP_Debug ] [ all elements ]

Full example


1 <?php
2 /**
3 * Full Tutorial
4 *
5 * @package PHP_Debug
6 * @filesource
7 */
8
9 /**
10 */
11 print("<html><head></head><body bgcolor=white><h1>PHP_Debug :: Hello World !!</h1>");
12
13
14 // =================================================================================
15
16 // Include the Debug Class
17 include_once('debug.php');
18
19 // Create the debug object with passing the current file name
20 $Dbg = new Debug();
21
22
23 // == Change default settings of debug object ======================================
24
25 // Set url of view source script
26 $Dbg->ViewSourceScriptPath = ".";
27 $Dbg->ViewSourceScriptName = "source.php";
28
29 // Set PHPMyAdmin config
30 $Dbg->PhpMyAdminUrl = "http://127.0.0.1/mysql";
31 $Dbg->DatabaseName = "mysql";
32
33 // Use _REQUEST array instead of _GET + _POST + _FILES + _COOKIE arrays
34 $Dbg->UseRequestArr = false;
35
36
37 // == Then we can add debug infos :) ===============================================
38
39 // Add current processed file
40 $Dbg->addDebug("",DBGLINE_CURRENTFILE,__FILE__);
41
42
43 // Define Action
44 $action = "PHP_DEBUG_BASIC";
45 // Debug current action processed
46 $Dbg->addDebug($action,DBGLINE_PAGEACTION,__FILE__,__LINE__);
47
48
49 // This the simplest debug info ( see full doc for debugline type constants )
50 $Dbg->addDebug("This is my first debug info !",DBGLINE_STD,__FILE__,__LINE__);
51
52
53 // Let's debug a query
54 $field = "host, user";
55 $table = "user";
56 $sql = "SELECT $field FROM $table";
57
58 // Add the query in the debug infos
59 $Dbg->addDebug($sql,DBGLINE_QUERY,__FILE__,__LINE__);
60
61
62 // Now we ckeck the process time of the query, start timer
63 $Dbg->DebugPerf(DBGLINE_QUERY);
64
65 // ... Execute you query ...
66 for ( $i = 0 ; $i < 100000 ; $i++ ) { $z = $i; }
67 // ... Execute you query ...
68
69 // Now we stop the timer ( same function with same parameter )
70 $Dbg->DebugPerf(DBGLINE_QUERY);
71
72
73 // Check CPU Process time of a part of code
74
75 // How many iterations ?
76 $PerfCpt = 300000;
77
78 // Text of the debug info
79 $Dbg->addDebug("Analyse the performance of a <b>for</b> statement of $PerfCpt iterations.",DBGLINE_STD,__FILE__,__LINE__);
80
81 // Start the process time evaluation
82 $Dbg->DebugPerf(DBGLINE_STD);
83 $z = 0;
84 for ( $i = 0 ; $i < 300000 ; $i++ )
85 {
86 $z = $i;
87 // ... your code ...
88 }
89 // Stop the process time evaluation
90 $Dbg->DebugPerf(DBGLINE_STD);
91
92
93 // Let's debug an array...
94 // We can also call this function with debug object "Dbg->DumpArr($arr,'Debug Variable $arr (array) Function DumpArr()');"
95
96 $arr = array( array( 1 => "aaaaaaa" ,
97 2 => "bbbbb" ) ,
98
99 array( 7 => "ccccccc" ,
100 8 => "dddddd" ),
101
102 "The Array Says..." => "I'am an array, you can easly see what is inside of me with PHP_Debug, This class rox ! :p"
103 );
104
105 Debug::DumpArr($arr,'Debug Variable $arr (array) Function DumpArr()');
106
107 // ... or include it in the debug infos.
108 $Dbg->addDebug($arr,DBGLINE_OBJECT,__FILE__,__LINE__,'Debug Variable $arr (array) Function DumpObj(), (same as DumpObj() is Pear disabled)');
109
110 // You can debug the debug object itelf, remove comment to see what is inside.
111 //Debug::DumpArr($Dbg,'Debug Object');
112
113 // Now dislay the debug infos ( End of page or wherever you want )
114 // ( Eventually passing a string to search and the mode of debug display )
115
116 $Dbg->DebugDisplay( (isset($_REQUEST["DBG_SEARCH"]) ? $_REQUEST["DBG_SEARCH"] : "") , DBG_MODE_AUTO );
117
118 // == Check documentation for full details. :) ===========================================
119
120 print("</body></html>");
121 ?>

Documentation generated on Mon, 15 Dec 2003 18:46:42 +0100 by phpDocumentor 1.2.3