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

Source for file debug_test.php

Documentation is available at debug_test.php

  1. <?php
  2. /**
  3. * Full Tutorial
  4. *
  5. * @package PHP_Debug
  6. * @filesource
  7. */
  8.  
  9. // Global var
  10. include_once('../includes/setup.php');
  11.  
  12. // Include the Debug Class
  13. include_once("$debugClassLocation/debug.php");
  14.  
  15. // Current file
  16. $file = 'debug_test.php';
  17.  
  18. // Create the debug object
  19. $Dbg = &new Debug(DBG_MODE_FULL);
  20.  
  21. // Generate XHTML
  22. $Dbg->genXHTMLOutput = true;
  23.  
  24.  
  25. /**
  26. * Begin output
  27. */
  28. print('<?xml version="1.0" encoding="UTF-8"?>');
  29.  
  30. ?>
  31.  
  32. <!DOCTYPE html
  33. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  34. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  35. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
  36. <head>
  37. <title>PHP_Debug :: Hello World !!</title>
  38. <style type="text/css">
  39. body {
  40. background-color:#FFFFFF;
  41. padding:1px;
  42. margin:1px;
  43. }
  44. img {
  45. border-width:0 0 0 0;
  46. }
  47. hr {
  48. height: 1px;
  49. border-style: solid;
  50. border-color: #c0c0c0;
  51. margin-top: 10px;
  52. margin-bottom: 10px;
  53. }
  54. </style>
  55. <?php
  56.  
  57. /**
  58. * Generate StyleSheet
  59. */
  60. print($Dbg->generateStyleSheet());
  61.  
  62. ?>
  63.  
  64. </head>
  65. <body>
  66. <?php
  67.  
  68. // == Change default settings of debug object =================================
  69. // Set url of view source script
  70.  
  71. $Dbg->ViewSourceScriptPath = "../sources";
  72. $Dbg->ViewSourceScriptName = "source.php";
  73.  
  74. // Set PHPMyAdmin config
  75. $Dbg->setPhpMyAdminUrl("http://127.0.0.1/mysql");
  76. $Dbg->setDatabaseName("mysql");
  77.  
  78. // Use _REQUEST array instead of _GET + _POST + _FILES + _COOKIE arrays
  79. $Dbg->UseRequestArr = false;
  80.  
  81. // Set Max query line length to display big queries on multiple line
  82. $Dbg->maxQueryLineLength = 110;
  83.  
  84.  
  85. // Some display
  86. print("<div align=\"center\"><h1>&laquo; PHP_Debug :: Hello World !! &raquo;</h1></div>");
  87. print("<div><hr><h2>Click <a href=\"../sources/source.php?script=". $HTTP_SERVER_VARS['SCRIPT_FILENAME']. "\">here</a> to see the source code of this page.</h2></div>");
  88.  
  89.  
  90. // == Then we can add debug infos :) ==========================================
  91. // Add current processed file
  92.  
  93. $Dbg->addDebug('', DBGLINE_CURRENTFILE, __FILE__, __LINE__);
  94.  
  95. // Define Action
  96. $action = 'PHP_DEBUG_BASIC';
  97. // Debug current action processed
  98. $Dbg->addDebug($action, DBGLINE_PAGEACTION, __FILE__, __LINE__);
  99.  
  100.  
  101. // This the simplest debug info ( see full doc for debugline type constants )
  102. $Dbg->addDebug("This is my first debug info !", DBGLINE_STD, __FILE__, __LINE__);
  103.  
  104.  
  105. // Let's debug a query
  106. $field = 'host, user';
  107. $table = 'USERS';
  108. $sql = "SELECT * FROM $table";
  109. $badsql = "SELECT * F ,sdROM USERS;";
  110.  
  111.  
  112. // Add the query in the debug infos
  113. $Dbg->addDebug($sql, DBGLINE_QUERY, __FILE__, __LINE__);
  114.  
  115. // Now we ckeck the process time of the query, start timer
  116. $Dbg->DebugPerf(DBGLINE_QUERY);
  117.  
  118. // ... Execute your query ...
  119. for ($i = 0 ; $i < 100000 ; $i++) {$z = $i;}
  120. // ... Execute you query ...
  121. // Now we stop the timer ( same function with same parameter )
  122.  
  123. $Dbg->DebugPerf(DBGLINE_QUERY);
  124.  
  125.  
  126. // This the simplest debug info ( see full doc for debugline type constants )
  127. $Dbg->addDebug("Now test the <b>Pear::SQL_Parser</b> (Pear must be enabled)", DBGLINE_STD, __FILE__, __LINE__);
  128.  
  129. // This the simplest debug info ( see full doc for debugline type constants )
  130. $Dbg->addDebug("to enable the SQL parser, set <b>DBG_VERSION</b> to <b>DBG_VERSION_PEAR</b> in debug.php (top of the file)", DBGLINE_STD, __FILE__, __LINE__);
  131.  
  132. // Add a query with a parse error
  133. $Dbg->addDebug($badsql, DBGLINE_QUERY, __FILE__, __LINE__);
  134.  
  135.  
  136. // Check CPU Process time of a part of code
  137. // How many iterations ?
  138.  
  139. $PerfCpt = 300;
  140.  
  141. // Text of the debug info
  142. $Dbg->addDebug("Analyse the performance of a <b>for</b>
  143. statement of $PerfCpt iterations.", DBGLINE_STD,
  144. __FILE__, __LINE__);
  145.  
  146. // Start the process time evaluation
  147. $Dbg->DebugPerf(DBGLINE_STD);
  148. $z = 0;
  149. for ($i = 0 ; $i < $PerfCpt ; $i++)
  150. {
  151. $z = $i;
  152. // ... your code ...
  153. }
  154. // Stop the process time evaluation
  155. $Dbg->DebugPerf(DBGLINE_STD);
  156.  
  157.  
  158. // Let's debug an array...
  159. // We can also call this function with debug object
  160. // "Dbg->DumpArr($arr,'Debug Variable $arr (array) Function DumpArr()');"
  161.  
  162.  
  163.  
  164. $arr = array( array( 1 => "aaaaaaa" ,
  165. 2 => "bbbbb" ) ,
  166.  
  167. array( 7 => "ccccccc" ,
  168. 8 => "dddddd" ),
  169. "The Array Says..." => "I'am an array, you can easly see what
  170. is inside of me with PHP_Debug, This class rox ! :p"
  171. );
  172.  
  173. print("<hr>");
  174.  
  175. Debug::DumpArr($arr,'Debug Variable $arr (array) Function DumpArr()');
  176.  
  177. print("<hr>");
  178.  
  179. Debug::DumpObj($arr, 'Debug Variable $arr (array) Function DumpObj() (same as DumpObj() if Pear is disabled)');
  180.  
  181. print("<hr>");
  182.  
  183. // ... or include it in the debug infos.
  184. $Dbg->addDebug($arr, DBGLINE_OBJECT, __FILE__, __LINE__,'Debug Variable $arr
  185. (array) Function DumpObj(), (same as DumpObj() if Pear is disabled)');
  186.  
  187.  
  188. // Now dislay the debug infos ( End of page or wherever you want )
  189. $Dbg->DebugDisplay();
  190. // == Check documentation for full details. :) ================================
  191.  
  192.  
  193. print("</div></body></html>");
  194. ?>

Documentation generated on Sun, 12 Jun 2005 14:52:25 +0200 by phpDocumentor 1.3.0RC3